|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
Extends the Serializable interface to support custom XML serialization.
Only the identity of the class of an XmlExternalizable instance
is written as Element in the DOM tree and it is the responsibility of
the class to save and restore the contents of its instances.
The writeXmlExternal and readXmlExternal methods of the
XmlExternalizable interface are implemented by a class to give
the class complete control over the format and contents of the
stream for an object and its supertypes. These methods must
explicitly coordinate with the supertype to save its state.
These methods supercede customized implementations of writeObject and readObject
methods.
XML object Serialization uses the Serializable, XmlExternalizable
and Externalizable interfaces. Object persistence mechanisms can
use them as well. Each object to be stored is tested for the
XmlExternalizable interface first. If the object supports
XmlExternalizable, the writeXmlExternal method is called.
If the object does not support XmlExternalizable a similar check is done
for the Externalizable interface. If the object does implement
Serializable, the object is saved using XmlWriter or XmlObjectOutput
wrapper.
When an XmlExternalizable or Externalizable object is reconstructed,
an instance is created using the public no-arg constructor,
then the readXmlExternal or readExternal methods are called.
Serializable objects are restored by reading them from an XmlReader
or XmlObjectInput.
XmlTools doen't support substitution object via the writeReplace
and readResolve methods documented in the Serializable interface.
| Method Summary | |
void |
readXmlExternal(XmlReader in)
The object implements the readXmlExternal method to restore its contents by calling the methods of XmlReader for primitive types and readObject for objects, strings and arrays. |
void |
writeXmlExternal(XmlWriter out)
The object implements the writeXmlExternal method to save its contents by calling the methods of XmlWriter for its primitive values or calling the writeObject for objects, strings, and arrays. |
| Method Detail |
public void writeXmlExternal(XmlWriter out)
throws XmlToolsException
out - - the destination DOM tree to write the object to
XmlToolsException
public void readXmlExternal(XmlReader in)
throws XmlToolsException
in - the DOM reader to read data from in order to restore the object
XmlToolsException
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||