public class XMLMarshaller extends org.eclipse.persistence.internal.oxm.XMLMarshaller<org.eclipse.persistence.internal.sessions.AbstractSession,CharacterEscapeHandler,XMLContext,XMLDescriptor,XMLMarshalListener,MediaType,NamespacePrefixMapper,org.eclipse.persistence.internal.oxm.TreeObjectBuilder,DatabaseSession> implements java.lang.Cloneable
Class used to marshal object to XML.
Create an XMLMarshaller from an XMLContext.
Code Sample
XMLContext context = new XMLContext("mySessionName");
XMLMarshaller marshaller = context.createMarshaller();
Objects can be marshalled to the following outputs:
Objects that can be marshalled are those which are mapped in the TopLink project associated with the XMLContext, and which are mapped to an XMLDescriptor that has a default root element specified.
XMLContext
attachmentMarshaller, DEFAULT_XML_VERSION, domToEventWriterClass, domToStreamWriterClass, mediaType, staxResultClass, staxResultGetEventWriterMethod, staxResultGetStreamWriterMethod, transformer, writeToEventWriterMethod, writeToStreamMethod
Modifier | Constructor and Description |
---|---|
|
XMLMarshaller(XMLContext xmlContext)
Create a new XMLMarshaller based on the specified session
|
protected |
XMLMarshaller(XMLMarshaller xmlMarshaller)
Copy constructor
|
Modifier and Type | Method and Description |
---|---|
XMLMarshaller |
clone() |
CharacterEscapeHandler |
getCharacterEscapeHandler()
Return this Marshaller's CharacterEscapeHandler.
|
protected XMLDescriptor |
getDescriptor(java.lang.Object object,
org.eclipse.persistence.internal.sessions.AbstractSession session,
boolean isXMLRoot) |
org.eclipse.persistence.internal.oxm.JsonTypeConfiguration |
getJsonTypeConfiguration()
Returns json type configuration.
|
XMLMarshalListener |
getMarshalListener() |
MediaType |
getMediaType()
Get the MediaType for this xmlMarshaller.
|
NamespacePrefixMapper |
getNamespacePrefixMapper()
NamespacePrefixMapper that can be used during marshal (instead of those set in the project meta data)
|
protected org.w3c.dom.Node |
getNode(java.lang.Object object,
org.w3c.dom.Node parentNode,
org.eclipse.persistence.internal.sessions.AbstractSession session,
XMLDescriptor xmlDescriptor,
boolean isXMLRoot) |
java.util.Properties |
getProperties()
Return a properties object for a given instance of the
XMLMarshaller.
|
XMLContext |
getXMLContext()
Return the instance of XMLContext that was used to create this instance
of XMLMarshaller.
|
protected void |
marshal(java.lang.Object object,
org.eclipse.persistence.internal.sessions.AbstractSession session,
MarshalRecord marshalRecord)
Convert the given object to XML and update the given marshal record with
that XML Document.
|
void |
marshal(java.lang.Object object,
javax.xml.transform.Result result)
PUBLIC:
Convert the given object to XML and update the given result with that XML Document
|
org.w3c.dom.Document |
objectToXML(java.lang.Object object,
org.w3c.dom.Node parent)
Deprecated.
|
org.w3c.dom.Document |
objectToXML(java.lang.Object object,
org.w3c.dom.Node parent,
DocumentPreservationPolicy docPresPolicy) |
org.w3c.dom.Document |
objectToXML(java.lang.Object object,
org.w3c.dom.Node rootNode,
XMLDescriptor descriptor,
XMLRecord xmlRow,
boolean isXMLRoot,
DocumentPreservationPolicy docPresPolicy) |
protected org.w3c.dom.Document |
objectToXML(java.lang.Object object,
XMLDescriptor descriptor,
boolean isXMLRoot)
INTERNAL:
Convert the given object to an XML Document
|
org.w3c.dom.Document |
objectToXML(java.lang.Object object,
XMLDescriptor descriptor,
XMLRecord xmlRow,
boolean isXMLRoot,
DocumentPreservationPolicy docPresPolicy)
INTERNAL:
Convert the given object to an XML Document
|
protected org.w3c.dom.Node |
objectToXMLNode(java.lang.Object object,
org.w3c.dom.Node rootNode,
org.eclipse.persistence.internal.sessions.AbstractSession session,
XMLDescriptor descriptor,
boolean isXMLRoot) |
void |
setCharacterEscapeHandler(CharacterEscapeHandler c)
Set this Marshaller's CharacterEscapeHandler.
|
void |
setMarshalListener(XMLMarshalListener listener) |
void |
setMediaType(MediaType mediaType)
Set the MediaType for this xmlMarshaller.
|
void |
setNamespacePrefixMapper(NamespacePrefixMapper mapper)
NamespacePrefixMapper that can be used during marshal (instead of those set in the project meta data)
|
void |
setXMLContext(XMLContext value)
Set the XMLContext used by this instance of XMLMarshaller.
|
void |
setXMLMarshalHandler(XMLMarshalListener marshalListener) |
addDescriptorNamespacesToXMLRecord, copyNamespaces, getAttachmentMarshaller, getAttributePrefix, getDescriptor, getDescriptor, getDescriptor, getDescriptor, getDescriptor, getDescriptor, getMarshalAttributeGroup, getNamespaceSeparator, getNoNamespaceSchemaLocation, getSchema, getSchemaLocation, getTransformer, getValueWrapper, getXmlHeader, isApplicationJSON, isApplicationXML, isFragment, isIncludeRoot, isMarshalEmptyCollections, isReduceAnyArrays, isSimpleXMLRoot, isWrapperAsCollectionName, marshal, marshal, marshal, marshal, marshal, marshal, marshal, objectToXML, objectToXMLNode, setAttachmentMarshaller, setAttributePrefix, setEncoding, setFormattedOutput, setFragment, setIncludeRoot, setMarshalAttributeGroup, setMarshalEmptyCollections, setNamespaceSeparator, setNoNamespaceSchemaLocation, setReduceAnyArrays, setSchema, setSchemaLocation, setValueWrapper, setWrapperAsCollectionName, setXmlHeader
public XMLMarshaller(XMLContext xmlContext)
xmlContext
- the XML contentprotected XMLMarshaller(XMLMarshaller xmlMarshaller)
public XMLContext getXMLContext()
public void setXMLContext(XMLContext value)
public java.util.Properties getProperties()
public void setXMLMarshalHandler(XMLMarshalListener marshalListener)
public void marshal(java.lang.Object object, javax.xml.transform.Result result) throws XMLMarshalException
marshal
in class org.eclipse.persistence.internal.oxm.XMLMarshaller<org.eclipse.persistence.internal.sessions.AbstractSession,CharacterEscapeHandler,XMLContext,XMLDescriptor,XMLMarshalListener,MediaType,NamespacePrefixMapper,org.eclipse.persistence.internal.oxm.TreeObjectBuilder,DatabaseSession>
object
- the object to marshalresult
- the result to marshal the object toXMLMarshalException
- if an error occurred during marshallingprotected org.w3c.dom.Node getNode(java.lang.Object object, org.w3c.dom.Node parentNode, org.eclipse.persistence.internal.sessions.AbstractSession session, XMLDescriptor xmlDescriptor, boolean isXMLRoot)
getNode
in class org.eclipse.persistence.internal.oxm.XMLMarshaller<org.eclipse.persistence.internal.sessions.AbstractSession,CharacterEscapeHandler,XMLContext,XMLDescriptor,XMLMarshalListener,MediaType,NamespacePrefixMapper,org.eclipse.persistence.internal.oxm.TreeObjectBuilder,DatabaseSession>
public XMLMarshalListener getMarshalListener()
getMarshalListener
in class org.eclipse.persistence.internal.oxm.Marshaller<CharacterEscapeHandler,XMLContext,XMLMarshalListener,MediaType,NamespacePrefixMapper>
public void setMarshalListener(XMLMarshalListener listener)
setMarshalListener
in class org.eclipse.persistence.internal.oxm.Marshaller<CharacterEscapeHandler,XMLContext,XMLMarshalListener,MediaType,NamespacePrefixMapper>
protected void marshal(java.lang.Object object, org.eclipse.persistence.internal.sessions.AbstractSession session, MarshalRecord marshalRecord)
object
- the object to marshalmarshalRecord
- the marshalRecord to marshal the object toprotected org.w3c.dom.Document objectToXML(java.lang.Object object, XMLDescriptor descriptor, boolean isXMLRoot) throws XMLMarshalException
objectToXML
in class org.eclipse.persistence.internal.oxm.XMLMarshaller<org.eclipse.persistence.internal.sessions.AbstractSession,CharacterEscapeHandler,XMLContext,XMLDescriptor,XMLMarshalListener,MediaType,NamespacePrefixMapper,org.eclipse.persistence.internal.oxm.TreeObjectBuilder,DatabaseSession>
object
- the object to marshaldescriptor
- the XMLDescriptor for the object being marshalledXMLMarshalException
- if an error occurred during marshallingprotected org.w3c.dom.Node objectToXMLNode(java.lang.Object object, org.w3c.dom.Node rootNode, org.eclipse.persistence.internal.sessions.AbstractSession session, XMLDescriptor descriptor, boolean isXMLRoot) throws XMLMarshalException
objectToXMLNode
in class org.eclipse.persistence.internal.oxm.XMLMarshaller<org.eclipse.persistence.internal.sessions.AbstractSession,CharacterEscapeHandler,XMLContext,XMLDescriptor,XMLMarshalListener,MediaType,NamespacePrefixMapper,org.eclipse.persistence.internal.oxm.TreeObjectBuilder,DatabaseSession>
XMLMarshalException
public org.w3c.dom.Document objectToXML(java.lang.Object object, org.w3c.dom.Node parent) throws XMLMarshalException
object
- the object to marshalparent
- the node to marshal the object toXMLMarshalException
- if an error occurred during marshallingpublic org.w3c.dom.Document objectToXML(java.lang.Object object, org.w3c.dom.Node parent, DocumentPreservationPolicy docPresPolicy)
public org.w3c.dom.Document objectToXML(java.lang.Object object, XMLDescriptor descriptor, XMLRecord xmlRow, boolean isXMLRoot, DocumentPreservationPolicy docPresPolicy)
public org.w3c.dom.Document objectToXML(java.lang.Object object, org.w3c.dom.Node rootNode, XMLDescriptor descriptor, XMLRecord xmlRow, boolean isXMLRoot, DocumentPreservationPolicy docPresPolicy)
protected XMLDescriptor getDescriptor(java.lang.Object object, org.eclipse.persistence.internal.sessions.AbstractSession session, boolean isXMLRoot)
public XMLMarshaller clone()
clone
in class java.lang.Object
public void setNamespacePrefixMapper(NamespacePrefixMapper mapper)
setNamespacePrefixMapper
in class org.eclipse.persistence.internal.oxm.Marshaller<CharacterEscapeHandler,XMLContext,XMLMarshalListener,MediaType,NamespacePrefixMapper>
public NamespacePrefixMapper getNamespacePrefixMapper()
getNamespacePrefixMapper
in class org.eclipse.persistence.internal.oxm.Marshaller<CharacterEscapeHandler,XMLContext,XMLMarshalListener,MediaType,NamespacePrefixMapper>
public CharacterEscapeHandler getCharacterEscapeHandler()
getCharacterEscapeHandler
in class org.eclipse.persistence.internal.oxm.Marshaller<CharacterEscapeHandler,XMLContext,XMLMarshalListener,MediaType,NamespacePrefixMapper>
public void setCharacterEscapeHandler(CharacterEscapeHandler c)
setCharacterEscapeHandler
in class org.eclipse.persistence.internal.oxm.Marshaller<CharacterEscapeHandler,XMLContext,XMLMarshalListener,MediaType,NamespacePrefixMapper>
public void setMediaType(MediaType mediaType)
setMediaType
in class org.eclipse.persistence.internal.oxm.XMLMarshaller<org.eclipse.persistence.internal.sessions.AbstractSession,CharacterEscapeHandler,XMLContext,XMLDescriptor,XMLMarshalListener,MediaType,NamespacePrefixMapper,org.eclipse.persistence.internal.oxm.TreeObjectBuilder,DatabaseSession>
mediaType
- public MediaType getMediaType()
public org.eclipse.persistence.internal.oxm.JsonTypeConfiguration getJsonTypeConfiguration()
getJsonTypeConfiguration
in class org.eclipse.persistence.internal.oxm.Marshaller<CharacterEscapeHandler,XMLContext,XMLMarshalListener,MediaType,NamespacePrefixMapper>