|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.dom4j.tree.AbstractNode
org.dom4j.tree.AbstractBranch
org.dom4j.tree.AbstractElement
org.dom4j.tree.DefaultElement
de.fu_berlin.ties.io.ObjectElement
public class ObjectElement
An XML element that is targeted at storing an Java object.
Field Summary | |
---|---|
static String |
JAVA_CLASS_ATTRIBUTE
The name of the attribute used to store the Java class of an object: "java". |
Fields inherited from class org.dom4j.tree.AbstractElement |
---|
EMPTY_ITERATOR, EMPTY_LIST, USE_STRINGVALUE_SEPARATOR, VERBOSE_TOSTRING |
Fields inherited from class org.dom4j.tree.AbstractBranch |
---|
DEFAULT_CONTENT_LIST_SIZE |
Fields inherited from class org.dom4j.tree.AbstractNode |
---|
NODE_TYPE_NAMES |
Fields inherited from interface org.dom4j.Node |
---|
ANY_NODE, ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_REFERENCE_NODE, MAX_NODE_TYPE, NAMESPACE_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE, UNKNOWN_NODE |
Constructor Summary | |
---|---|
ObjectElement(QName qname,
Class javaClass)
Creates a new instance. |
|
ObjectElement(String name,
Class javaClass)
Creates a new instance. |
|
ObjectElement(String name,
Namespace namespace,
Class javaClass)
Creates a new instance. |
Method Summary | |
---|---|
static Object |
createNextObject(Iterator iter)
Uses the next element returned by an iterator to initialize an object. |
Object |
createObject()
Creates (deserializes) an object of a specified type by calling a constructor of the class that accepts an XML element as single argument and passing itself as parameter. |
static Object |
createObject(Document document)
Convenience method that delegates to createObject(Element) ,
using the root element of a given document. |
static Object |
createObject(Element element)
Creates (deserializes) an object of a specified type by calling a constructor of the class that accepts an XML element as single argument and passing itself as parameter. |
static Object |
createObject(Element element,
Class type)
Creates (deserializes) an object of a specified type by calling a constructor of the class that accepts an XML element as single argument and passing itself as parameter. |
static Object |
createObject(File file)
Convenience method that delegates to createObject(Document) ,
reading from a file. |
Class |
javaClass()
Returns the Class of the stored object. |
static Class |
javaClass(Element element)
Looks up and returns the Class of a Java object stored in an
element. |
String |
javaClassName()
Returns the name of the Class of the stored object. |
static String |
javaClassName(Element element)
Looks up and returns the name of the Class of Java object stored
in an element. |
static String |
recommendedExtension()
Returns the file extension recommended for serializing Java code. |
void |
store(File file,
TiesConfiguration conf)
Writes this object element document to a file, consulting a given configuration about whether to use compression. |
void |
store(OutputStream out)
Writes this object element document to an output stream. |
ObjectElement |
unsetJavaClass()
Unsets the attribute representing the Class of the stored object. |
Methods inherited from class org.dom4j.tree.AbstractBranch |
---|
addElement, addElement, addElement, appendContent, content, contentRemoved, createContentList, createContentList, createEmptyList, createResultList, createSingleResultList, elementByID, elementID, getContentAsStringValue, getContentAsText, getTextTrim, hasContent, invalidNodeTypeAddException, isReadOnly, setProcessingInstructions |
Methods inherited from class org.dom4j.tree.AbstractNode |
---|
asXPathResult, createPattern, createXPath, createXPathFilter, createXPathResult, detach, getNodeTypeName, getPath, getUniquePath, matches, numberValueOf, selectNodes, selectNodes, selectNodes, selectObject, selectSingleNode, valueOf |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.dom4j.Element |
---|
getTextTrim |
Methods inherited from interface org.dom4j.Branch |
---|
addElement, addElement, appendContent, content, elementByID, setProcessingInstructions |
Methods inherited from interface org.dom4j.Node |
---|
asXPathResult, createXPath, detach, getNodeTypeName, getPath, getUniquePath, hasContent, isReadOnly, matches, numberValueOf, selectNodes, selectNodes, selectNodes, selectObject, selectSingleNode, valueOf |
Field Detail |
---|
public static final String JAVA_CLASS_ATTRIBUTE
Constructor Detail |
---|
public ObjectElement(String name, Class javaClass)
name
- the name of the elementjavaClass
- the class of the object to store; or null
if no class should be storedpublic ObjectElement(QName qname, Class javaClass)
qname
- the qualified name of the elementjavaClass
- the class of the object to store; or null
if no class should be storedpublic ObjectElement(String name, Namespace namespace, Class javaClass)
name
- the local name of the elementnamespace
- the namespace of the elementjavaClass
- the class of the object to store; or null
if no class should be storedMethod Detail |
---|
public static final Object createNextObject(Iterator iter) throws InstantiationException, SecurityException, ClassCastException, NullPointerException
null
is returned.
iter
- an iterator over Element
s to use
createObject(Element)
on the
next element returned by the iterator; or null
if
Iterator.hasNext()
is false
InstantiationException
- if instantiation failed
SecurityException
- if access to the required reflection
information is denied
ClassCastException
- if the object returned by calling
Iterator.next()
does not implement the Element
interface
NullPointerException
- if no java class attribute is presentpublic static final Object createObject(File file) throws IOException, InstantiationException, SecurityException, NullPointerException
createObject(Document)
,
reading from a file.
file
- the file to read
IOException
- if an I/O error occurs while reading the data
InstantiationException
- if instantiation failed or if the class
specified in the JAVA_CLASS_ATTRIBUTE
of the root element is
not available on this system
SecurityException
- if access to the required reflection
information is denied
NullPointerException
- if no java class attribute is presentpublic static final Object createObject(Document document) throws InstantiationException, SecurityException, NullPointerException
createObject(Element)
,
using the root element of a given document.
document
- the document to use
InstantiationException
- if instantiation failed or if the class
specified in the JAVA_CLASS_ATTRIBUTE
of the root element is
not available on this system
SecurityException
- if access to the required reflection
information is denied
NullPointerException
- if no java class attribute is presentpublic static final Object createObject(Element element) throws InstantiationException, SecurityException, NullPointerException
element
- the element to use
InstantiationException
- if instantiation failed or if the class
specified in the JAVA_CLASS_ATTRIBUTE
is not available on this
system
SecurityException
- if access to the required reflection
information is denied
NullPointerException
- if no java class attribute is presentpublic static final Object createObject(Element element, Class type) throws InstantiationException, SecurityException
element
- the element to usetype
- the class of the object to create; must have a constructor
whose only argument is an Element
InstantiationException
- if instantiation failed
SecurityException
- if access to the required reflection
information is deniedpublic static String javaClassName(Element element)
Class
of Java object stored
in an element.
element
- the element to use
null
if
no JAVA_CLASS_ATTRIBUTE
is presentpublic static Class javaClass(Element element) throws ClassNotFoundException
Class
of a Java object stored in an
element.
element
- the element to use
null
if
no JAVA_CLASS_ATTRIBUTE
is present
ClassNotFoundException
- if the class cannot be locatedpublic static String recommendedExtension()
public final Object createObject() throws InstantiationException, SecurityException, ClassNotFoundException, NullPointerException
InstantiationException
- if instantiation failed
SecurityException
- if access to the required reflection
information is denied
ClassNotFoundException
- if the class specified in the
JAVA_CLASS_ATTRIBUTE
is not available on this system
NullPointerException
- if the java class attribute has been
removed (by calling unsetJavaClass()
public String javaClassName()
Class
of the stored object.
null
if
unsetJavaClass()
has been called beforepublic Class javaClass() throws ClassNotFoundException
Class
of the stored object.
null
if
unsetJavaClass()
has been called before
ClassNotFoundException
- if the class cannot be locatedpublic void store(File file, TiesConfiguration conf) throws IOException
file
- the file to write toconf
- used to decide whether to use compression
IOException
- if an I/O error occurs while writingpublic void store(OutputStream out) throws IOException
out
- the output stream to write to; not closed by this method
IOException
- if an I/O error occurs while writingpublic ObjectElement unsetJavaClass()
Class
of the stored object.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |