com.waveset.util
Interface XmlObjectHandler


public interface XmlObjectHandler

An interface that provides methods to transform objects to and from XML. This is typically used with the XmlObjectFactory to register handlers for classes that do not themselves implement the XmlObject interface but which we want to be able to serialize.

Most objects that will be serialized/deserialized as XML will simply implement the XmlObject interface, and make use of the default behavior provided by the XmlObjectFactory class.

Some classes may however want more control, and possibly not want to implement XmlObject. This is the case for the native Java classes like String, Integer, HashMap, ArrayList, etc. We will provide built-in handlers for those classes, but the list can be extended simply by registring another handler with XmlObjectFactory.


Field Summary
static java.lang.String code_id
           
static java.lang.String ELEMENT_BOOLEAN
           
static java.lang.String ELEMENT_DATE
           
static java.lang.String ELEMENT_INTEGER
           
static java.lang.String ELEMENT_LIST
           
static java.lang.String ELEMENT_LOCALE
           
static java.lang.String ELEMENT_LONG
           
static java.lang.String ELEMENT_MAP
           
static java.lang.String ELEMENT_NULL
           
static java.lang.String ELEMENT_STRING
           
static java.lang.String ELEMENT_X509CERTIFICATE
           
 
Method Summary
 java.lang.Object create(org.w3c.dom.Element e)
          Handlers that want to construct objects from XML must implement this method.
 java.lang.String getElementName()
          Handlers may return an element name to indicate which XML element they parse.
 java.lang.Class getHandledClass()
          Handlers that wish to serve as a serializer must return a Class object to indicate which class of objects they can serialize.
 void toXml(java.lang.StringBuffer b, int indent, java.lang.Object obj)
          Handlers that wish to serialize objects must implement this method.
 

Field Detail

code_id

public static final java.lang.String code_id
See Also:
Constant Field Values

ELEMENT_STRING

public static final java.lang.String ELEMENT_STRING
See Also:
Constant Field Values

ELEMENT_INTEGER

public static final java.lang.String ELEMENT_INTEGER
See Also:
Constant Field Values

ELEMENT_LONG

public static final java.lang.String ELEMENT_LONG
See Also:
Constant Field Values

ELEMENT_BOOLEAN

public static final java.lang.String ELEMENT_BOOLEAN
See Also:
Constant Field Values

ELEMENT_DATE

public static final java.lang.String ELEMENT_DATE
See Also:
Constant Field Values

ELEMENT_NULL

public static final java.lang.String ELEMENT_NULL
See Also:
Constant Field Values

ELEMENT_MAP

public static final java.lang.String ELEMENT_MAP
See Also:
Constant Field Values

ELEMENT_LIST

public static final java.lang.String ELEMENT_LIST
See Also:
Constant Field Values

ELEMENT_X509CERTIFICATE

public static final java.lang.String ELEMENT_X509CERTIFICATE
See Also:
Constant Field Values

ELEMENT_LOCALE

public static final java.lang.String ELEMENT_LOCALE
See Also:
Constant Field Values
Method Detail

getElementName

public java.lang.String getElementName()
Handlers may return an element name to indicate which XML element they parse.

Handlers are not required to return an element name, in which case they are presumably used only as an object factory.


create

public java.lang.Object create(org.w3c.dom.Element e)
                        throws WavesetException
Handlers that want to construct objects from XML must implement this method. This method will only be called if the factory also return a non-null name from the getElementName method.

Throws:
WavesetException

getHandledClass

public java.lang.Class getHandledClass()
Handlers that wish to serve as a serializer must return a Class object to indicate which class of objects they can serialize.

Handlers are not required to return a class object, in which case they are presumably only used for parsing XML.


toXml

public void toXml(java.lang.StringBuffer b,
                  int indent,
                  java.lang.Object obj)
Handlers that wish to serialize objects must implement this method. It will only be called if the handler returned a non-null Class object from the getHandledClass method. The supplied object will be of that class.