it.unimo.dbgroup.momis.XmlTools
Interface XmlExternalizable

All Superinterfaces:
java.io.Serializable
All Known Subinterfaces:
FullXmlExternalizable

public interface XmlExternalizable
extends java.io.Serializable

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

writeXmlExternal

public void writeXmlExternal(XmlWriter out)
                      throws XmlToolsException
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.

Parameters:
out - - the destination DOM tree to write the object to
Throws:
XmlToolsException

readXmlExternal

public void readXmlExternal(XmlReader in)
                     throws XmlToolsException
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. The readXmlExternal method must read the values in the same sequence and with the same types as were written by writeXmlExternal.

Parameters:
in - the DOM reader to read data from in order to restore the object
Throws:
XmlToolsException


Universita' di Modena e Reggio Emilia