public abstract class AbstractXMLObjectMarshaller extends Object implements Marshaller
Marshaller interface.
This class handles most of the boilerplate code:
| Modifier and Type | Field and Description |
|---|---|
private Logger |
log
Class logger.
|
private MarshallerFactory |
marshallerFactory
Factory for XMLObject Marshallers.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractXMLObjectMarshaller()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
Element |
marshall(XMLObject xmlObject)
Marshall this element, and its children, and root them in a newly created Document.
|
Element |
marshall(XMLObject xmlObject,
Document document)
Marshall this element, and its children, into a W3C DOM element.
|
Element |
marshall(XMLObject xmlObject,
Element parentElement)
Marshall the given XMLObject and append it as a child to the given parent element.
|
protected void |
marshallAttributes(XMLObject xmlObject,
Element domElement)
Marshalls a given XMLObject into a W3C Element.
|
protected void |
marshallChildElements(XMLObject xmlObject,
Element domElement)
Marshalls the child elements of the given XMLObject.
|
protected void |
marshallElementContent(XMLObject xmlObject,
Element domElement)
Marshalls data from the XMLObject into content of the DOM Element.
|
protected Element |
marshallInto(XMLObject xmlObject,
Element targetElement)
Marshalls the given XMLObject into the given DOM Element.
|
protected void |
marshallNamespacePrefix(XMLObject xmlObject,
Element domElement)
Marshalls the namespace prefix of the XMLObject into the DOM element.
|
protected void |
marshallNamespaces(XMLObject xmlObject,
Element domElement)
Creates the xmlns attributes for any namespaces set on the given XMLObject.
|
protected void |
marshallSchemaInstanceAttributes(XMLObject xmlObject,
Element domElement)
Creates the XSI type, schemaLocation, and noNamespaceSchemaLocation attributes for an XMLObject.
|
protected void |
marshallUnknownAttributes(AttributeExtensibleXMLObject xmlObject,
Element domElement)
Marshalls unknown attributes.
|
private void |
prepareForAdoption(XMLObject domCachingObject)
Prepares the given DOM caching XMLObject for adoption into another document.
|
protected void |
setDocumentElement(Document document,
Element element)
Sets the given element as the Document Element of the given Document.
|
@Nonnull private final MarshallerFactory marshallerFactory
@Nonnull public Element marshall(@Nonnull XMLObject xmlObject) throws MarshallingException
DocumentBuilder obtained from a DocumentBuilderFactory
created without any additional parameters or properties set; that is the system defaults properties are used.marshall in interface MarshallerxmlObject - the object to marshallMarshallingException - thrown if there is a problem marshalling the given object@Nonnull public Element marshall(@Nonnull XMLObject xmlObject, @Nonnull Document document) throws MarshallingException
marshall in interface MarshallerxmlObject - the object to marshalldocument - the DOM document the marshalled element will be placed inMarshallingException - thrown if there is a problem marshalling the given object@Nonnull public Element marshall(@Nonnull XMLObject xmlObject, @Nonnull Element parentElement) throws MarshallingException
marshall in interface MarshallerxmlObject - the XMLObject to be marshalledparentElement - the parent of the Element resulting from marshalling the given XMLObjectMarshallingException - thrown if the given XMLObject can not be marshalled.protected void setDocumentElement(@Nonnull Document document, @Nonnull Element element)
document - the documentelement - the Element that will serve as the Document Element@Nonnull protected Element marshallInto(@Nonnull XMLObject xmlObject, @Nonnull Element targetElement) throws MarshallingException
xmlObject - the XMLObject to marshalltargetElement - the Element into which the XMLObject is marshalled intoXMLObject is marshalled intoMarshallingException - thrown if there is a problem marshalling the objectprotected void marshallNamespacePrefix(@Nonnull XMLObject xmlObject, @Nonnull Element domElement)
xmlObject - the XMLObject being marshalleddomElement - the DOM element the XMLObject is being marshalled intoprotected void marshallChildElements(@Nonnull XMLObject xmlObject, @Nonnull Element domElement) throws MarshallingException
xmlObject - the XMLObject whose children will be marshalleddomElement - the DOM element that will recieved the marshalled childrenMarshallingException - thrown if there is a problem marshalling a child elementprotected void marshallNamespaces(@Nonnull XMLObject xmlObject, @Nonnull Element domElement)
xmlObject - the XMLObjectdomElement - the DOM element the namespaces will be added toprotected void marshallSchemaInstanceAttributes(@Nonnull XMLObject xmlObject, @Nonnull Element domElement) throws MarshallingException
xmlObject - the XMLObjectdomElement - the DOM element the namespaces will be added toMarshallingException - thrown if the schema type information is invalidprotected void marshallAttributes(@Nonnull XMLObject xmlObject, @Nonnull Element domElement) throws MarshallingException
xmlObject - the XMLObject to marshalldomElement - the W3C DOM elementMarshallingException - thrown if there is a problem marshalling the elementprotected void marshallElementContent(@Nonnull XMLObject xmlObject, @Nonnull Element domElement) throws MarshallingException
xmlObject - the XMLObjectdomElement - the DOM element recieving the contentMarshallingException - thrown if the textual content can not be added to the DOM elementprivate void prepareForAdoption(@Nonnull XMLObject domCachingObject) throws MarshallingException
domCachingObject - the XMLObject to prepare for adoptionMarshallingException - thrown if a namespace within the XMLObject's DOM subtree can not be resolved.protected void marshallUnknownAttributes(@Nonnull AttributeExtensibleXMLObject xmlObject, @Nonnull Element domElement)
xmlObject - the Object which has the unknown attributes/domElement - where to marshall them to.Copyright © 1999–2015. All rights reserved.