Interface ILcdXMLTypeMarshaller<T>
public interface ILcdXMLTypeMarshaller<T>
An A template for the
The
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.
A template for the marshalType
method
The marshalType
method should perform the following steps:
- Write all the attributes, and store them into the Java object.
- Write all the other contents (simple content and/or child elements).
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.
[...]
}
- Since:
- 9.0
-
Method Summary
Modifier and TypeMethodDescriptionvoid
marshalType
(T aObject, XMLStreamWriter aWriter, ILcdXMLDocumentContext aContext) Partially marshals (serializes) he specified Java object or content tree to an XML element via the specifiedXMLStreamWriter
.
-
Method Details
-
marshalType
void marshalType(T aObject, XMLStreamWriter aWriter, ILcdXMLDocumentContext aContext) throws XMLStreamException Partially marshals (serializes) he specified Java object or content tree to an XML element via the specifiedXMLStreamWriter
. 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.- Parameters:
aObject
- the object to be marshalled.aWriter
- the XMLStreamWriter to marshal the object to.aContext
- aILcdXMLDocumentContext
which can be used to store and retrieve information which is shared between multiple marshallers. This context is unique per marshalled XML document.- Throws:
XMLStreamException
- if any unexpected content occurs while marshalling the object.- Preconditions:
- The cursor should be positioned at the start tag of the element to be marshalled.
- Postconditions:
- The cursor should be left at the end tag of the last child element which could be marshalled by this marshaller.
-