|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.topologi.diffx.xml.XMLSerializer
public final class XMLSerializer
This class provides methods to serialize objects to XML.
There is no mechanism to prevent infinite loops if some objects (lists,...) reference themselves.
The underlying XML document is generated using an XML string buffer.
Constructor Summary | |
---|---|
XMLSerializer(XMLWriter xml)
Creates a new XML serializer using the specified XML writer. |
Method Summary | |
---|---|
XMLWriter |
getXML()
Returns the underlying XML document. |
void |
serialize(Object o,
String name)
Serialises the given object using the given name as element name. |
void |
serializeCollection(Collection<?> c)
Serialises the given Collection to xml. |
void |
serializeHashtable(Hashtable<?,?> h)
Serialise the given Hashtable to xml. |
void |
serializeObject(Object o)
Serialises the given object to xml by using the public methods getXXX() . |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XMLSerializer(XMLWriter xml)
xml
- The XML string buffer to be usedMethod Detail |
---|
public XMLWriter getXML()
public void serialize(Object o, String name) throws IOException
This implementation is recursive. It calls itself for fields which are not of primitive type.
o
- Object to be serialised as xmlname
- Name of object
IOException
- Should an I/O error occur.public void serializeCollection(Collection<?> c) throws IOException
Iterates over every object and call the serialize(java.lang.Object, java.lang.String)
method.
c
- The Collection to be serialised to XML
IOException
- Should an I/O error occur.public void serializeHashtable(Hashtable<?,?> h) throws IOException
Hashtable
to xml.
This methods only works if the Hashtable
contains String
objects.
h
- The hashtable to be serialized to XML
IOException
- Should an I/O error occur.public void serializeObject(Object o) throws IOException
getXXX()
.
This method calls every getXXX()
method from the object to get the
returned object and then calls the serialize(Object, String)
method with
the returned object and the name xxx in lower case.
o
- The object to be serialised as XML
IOException
- Should an I/O error occur.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |