Joda System API

org.joda.property.xml
Interface XMLConvertor

All Known Implementing Classes:
AbstractPropertyXMLConvertor, BeanXMLConvertor, CollectionPropertyXMLConvertor, DataPropertyXMLConvertor, LinkPropertyXMLConvertor, MapPropertyXMLConvertor

public interface XMLConvertor

XMLConvertor defines how XMLData will be extracted from and written to other objects (typcially properties and beans).

The interface returns data in the XMLData format, which is a minimal DOM structure. Each convertor should only return the XMLData structure for its own internal data passed on the passed in object. If the object contains references to other objects that have their own XML convertors, the content field should be set to the object.

Typically, this means that an XMLData instance has a number of children, each of which have either String or object content. However, if an object needs to create a more complex structure it can do.

Author:
Stephen Colebourne

Method Summary
 void buildXMLData(XMLConvertorContext context, XMLData parent, java.lang.Object object)
          Build the XMLData representation of the object passed in.
 void expandXMLData(XMLConvertorContext context, XMLData data)
          Expand the collapsed XMLData object passed in.
 boolean isConvertorFor(java.lang.Object object)
          Check to see if this convertor handles the object.
 

Method Detail

isConvertorFor

public boolean isConvertorFor(java.lang.Object object)
Check to see if this convertor handles the object.

Parameters:
object - the object to check
Returns:
true if convertor handles object

buildXMLData

public void buildXMLData(XMLConvertorContext context,
                         XMLData parent,
                         java.lang.Object object)
Build the XMLData representation of the object passed in. This method is typically used by a bean to add the details of it's properties.

To avoid the need to build the entire DOM tree, it is possible to return a collapsed XMLData object. This is typically where a bean holds a reference to another bean. A collapsed XMLData is created by setting the content to the referenced bean. The expandXMLData method will then be called to get that data at the appropriate time.

Parameters:
context - the context for the output
parent - the parent XMLData to add to
object - the object to convert

expandXMLData

public void expandXMLData(XMLConvertorContext context,
                          XMLData data)
Expand the collapsed XMLData object passed in. A collapsed XMLData is one where the content is other than a String. This method will then be called to expand out the next level of XML data (lazy instantiation).

The object (typically a bean) to expand is stored in the content field of the passed in XMLData.

Parameters:
context - the context for the output
data - the XMLData to add to

Joda System API

Copyright © 2001-2003 Stephen Colebourne. All Rights Reserved.