com.openharbor.beck.marshal
Interface Marshaller

All Known Implementing Classes:
DefaultMarshaller

public interface Marshaller

Converts an object to XML. Different source objects require different Marshaller classes. The best Marshaller for a given source object is ordinarily chosen by a MapToXML.

A Marshaller is re-entrant; that is, a single instance can convert from several sources, sequentially, concurrently or recursively.


Method Summary
 java.lang.String getText(java.lang.Object parent, Getter getter, java.lang.Object child, XMLWriter writer)
          Copy data as a String, for use as XML element text or an XML attribute value.
 XMLThing getXML(MapToXML mapper, java.lang.Object parent, Getter getter, XMLWriter writer)
          Choose the XML element or attribute name for a Java object.
 java.lang.Object getXMLSource(MapToXML mapper, java.lang.Object parent, Getter getter)
          The object from which the XML is mapped, or null to indicate that the XML does not correspond to an object.
 void marshal(MapToXML mapper, java.lang.Object parent, Getter getter, XMLThing tag, XMLWriter writer)
          Generate XML from an object and its contained objects (if any).
 

Method Detail

marshal

public void marshal(MapToXML mapper,
                    java.lang.Object parent,
                    Getter getter,
                    XMLThing tag,
                    XMLWriter writer)
             throws java.lang.Exception
Generate XML from an object and its contained objects (if any).

Parameters:
parent - the object that contains this one, or null if the containing object is unknown.
getter - a reference to the object to be mapped and its name (if any) in the parent.
tag - the desired element name and conditions, or null if unspecified.
writer - the stream wherein to marshal the generated XML.
Throws:
java.lang.Exception

getXML

public XMLThing getXML(MapToXML mapper,
                       java.lang.Object parent,
                       Getter getter,
                       XMLWriter writer)
                throws java.lang.Exception
Choose the XML element or attribute name for a Java object. If the returned thing is an element with a null value, the caller should output the element and also additional attributes and/or content mapped from the source object. If the returned thing is an attribute or an element with a non-null value, the caller should output the returned thing without additions.

Parameters:
getter - to be mapped to XML
parent - contains source
Returns:
an attribute name and value or an element name with a set of conditions, or null to indicate that this source should not be marshalled.
Throws:
java.lang.Exception

getText

public java.lang.String getText(java.lang.Object parent,
                                Getter getter,
                                java.lang.Object child,
                                XMLWriter writer)
                         throws java.lang.Exception
Copy data as a String, for use as XML element text or an XML attribute value.

Returns:
the text representation of the given child, or null to indicate that it's not representable as text.
Throws:
java.lang.Exception

getXMLSource

public java.lang.Object getXMLSource(MapToXML mapper,
                                     java.lang.Object parent,
                                     Getter getter)
The object from which the XML is mapped, or null to indicate that the XML does not correspond to an object.