org.simpleframework.xml.convert
Interface Converter<T>


public interface Converter<T>

The Converter object is used to convert an object to XML by intercepting the normal serialization process. When serializing an object the write method is invoked. This is provided with the object instance to be serialized and the OutputNode to use to write the XML. Values can be taken from the instance and transferred to the node.

For deserialization the read method is invoked. This is provided with the InputNode, which can be used to read the elements and attributes representing the member data of the object being deserialized. Once the object has been instantiated it must be returned.

Author:
Niall Gallagher
See Also:
AnnotationStrategy, RegistryStrategy

Method Summary
 T read(InputNode node)
          This read method is used to deserialize an object from the source XML.
 void write(OutputNode node, T value)
          This write method is used to serialize an object to XML.
 

Method Detail

read

T read(InputNode node)
       throws java.lang.Exception
This read method is used to deserialize an object from the source XML. The deserialization is performed using the XML node provided. This node can be used to read the XML elements and attributes in any format required. Once all of the data has been extracted an instance must be returned.

Parameters:
node - this is the node to deserialize the object from
Returns:
the object instance resulting from the deserialization
Throws:
java.lang.Exception

write

void write(OutputNode node,
           T value)
           throws java.lang.Exception
This write method is used to serialize an object to XML. The serialization should be performed in such a way that all of the objects values are represented by an element or attribute of the provided node. This ensures that it can be fully deserialized at a later time.

Parameters:
node - this is the node to serialized to object to
value - this is the value that is to be serialized
Throws:
java.lang.Exception