public interface ILcdXMLTypeMarshaller<T>
ILcdXMLTypeMarshaller
is responsible for marshalling (serializing) Java object graphs into XML data. More
precisely, a marshaller is responsible for marshalling instances of one (sometimes more) Java class, or, in case
of complex data structures, Java object graphs, into one specific XML Schema type. The XML data should be
written via the Streaming API for XML (StAX).
Please refer to the package documentation
for a general overview
of the XML Binding Framework.
The marshalType
method from this interface relates to the marshal
method of
the ILcdXMLMarshaller
interface as follows:
marshal
: this method performs the full marshalling process: it marshals a Java object or content tree
into a complete XML element.
marshalType
: this method only performs the marshalling of the contents of one
specific XML schema type. It should only write those attributes and child elements it was
written for. In contrast to the marshal method, it does not generate a complete XML element:
it should not write the start and end tag of the element to be marshalled.
marshalType
methodmarshalType
method should perform the following steps:
marshalType
method should delegate to the super type's
marshalType
method unmarshaller, between the writing of the attributes and writing of
the element's children.
The template below illustrates how a typical marshalType
method, delegating to a super
type marshaller, should look like:
public void marshalType( Object aObject, XMLStreamWriter aWriter, Map aContext ) throws XMLStreamException {
MyObject object = (MyObject) aObject;
// Write this type's attributes.
[...]
// Delegate to super type marshaller
super_type_unmarshaller.marshalType(aObject, aWriter, aContext);
// Write this type's simple content/children.
[...]
}
Modifier and Type | Method and Description |
---|---|
void |
marshalType(T aObject,
XMLStreamWriter aWriter,
ILcdXMLDocumentContext aContext)
Partially marshals (serializes) he specified Java object or content tree to an XML element via the specified
XMLStreamWriter . |
void marshalType(T aObject, XMLStreamWriter aWriter, ILcdXMLDocumentContext aContext) throws XMLStreamException
XMLStreamWriter
.
At the moment this method is called, the cursor should be positioned at the start tag of the element to be
marshalled. This method should write all attributes, simple content and child elements it can handle. It should NOT
write the start or end tag for the element itself.aObject
- the object to be marshalled.aWriter
- the XMLStreamWriter to marshal the object to.aContext
- a ILcdXMLDocumentContext
which can be used to store and retrieve information which is shared
between multiple marshallers. This context is unique per marshalled XML document.XMLStreamException
- if any unexpected content occurs while marshalling the object.