java.lang.Object
org.eclipse.persistence.internal.oxm.Marshaller<CharacterEscapeHandler,XMLContext,XMLMarshalListener,MediaType,NamespacePrefixMapper>
org.eclipse.persistence.internal.oxm.XMLMarshaller<AbstractSession,CharacterEscapeHandler,XMLContext,XMLDescriptor,XMLMarshalListener,MediaType,NamespacePrefixMapper,TreeObjectBuilder,DatabaseSession>
org.eclipse.persistence.oxm.XMLMarshaller
- All Implemented Interfaces:
Cloneable
public class XMLMarshaller
extends XMLMarshaller<AbstractSession,CharacterEscapeHandler,XMLContext,XMLDescriptor,XMLMarshalListener,MediaType,NamespacePrefixMapper,TreeObjectBuilder,DatabaseSession>
implements 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:
- java.io.OutputStream
- java.io.Writer
- javax.xml.transform.Result
- org.w3c.dom.Node
- org.xml.sax.ContentHandler
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.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.persistence.internal.oxm.Marshaller
Marshaller.Listener
-
Field Summary
Fields inherited from class org.eclipse.persistence.internal.oxm.XMLMarshaller
attachmentMarshaller, DEFAULT_XML_VERSION, domToEventWriterClass, domToStreamWriterClass, mediaType, staxResultClass, staxResultGetEventWriterMethod, staxResultGetStreamWriterMethod, transformer, writeToEventWriterMethod, writeToStreamMethod
Fields inherited from class org.eclipse.persistence.internal.oxm.Marshaller
context, mapper, marshalProperties
-
Constructor Summary
ModifierConstructorDescriptionXMLMarshaller
(XMLContext xmlContext) Create a new XMLMarshaller based on the specified sessionprotected
XMLMarshaller
(XMLMarshaller xmlMarshaller) Copy constructor -
Method Summary
Modifier and TypeMethodDescriptionclone()
Return this Marshaller's CharacterEscapeHandler.protected XMLDescriptor
getDescriptor
(Object object, AbstractSession session, boolean isXMLRoot) Returns json type configuration.Get the MediaType for this xmlMarshaller.NamespacePrefixMapper that can be used during marshal (instead of those set in the project meta data)protected Node
getNode
(Object object, Node parentNode, AbstractSession session, XMLDescriptor xmlDescriptor, boolean isXMLRoot) Return a properties object for a given instance of the XMLMarshaller.Return the instance of XMLContext that was used to create this instance of XMLMarshaller.void
PUBLIC: Convert the given object to XML and update the given result with that XML Documentprotected void
marshal
(Object object, AbstractSession session, MarshalRecord marshalRecord) Convert the given object to XML and update the given marshal record with that XML Document.protected Document
objectToXML
(Object object, XMLDescriptor descriptor, boolean isXMLRoot) INTERNAL: Convert the given object to an XML DocumentobjectToXML
(Object object, XMLDescriptor descriptor, XMLRecord xmlRow, boolean isXMLRoot, DocumentPreservationPolicy docPresPolicy) INTERNAL: Convert the given object to an XML DocumentobjectToXML
(Object object, Node parent, DocumentPreservationPolicy docPresPolicy) objectToXML
(Object object, Node rootNode, XMLDescriptor descriptor, XMLRecord xmlRow, boolean isXMLRoot, DocumentPreservationPolicy docPresPolicy) protected Node
objectToXMLNode
(Object object, Node rootNode, AbstractSession session, XMLDescriptor descriptor, boolean isXMLRoot) void
Set this Marshaller's CharacterEscapeHandler.void
setMarshalListener
(XMLMarshalListener listener) void
setMediaType
(MediaType mediaType) Set the MediaType for this xmlMarshaller.void
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) Methods inherited from class org.eclipse.persistence.internal.oxm.XMLMarshaller
addDescriptorNamespacesToXMLRecord, copyNamespaces, getAttachmentMarshaller, getAttributePrefix, getDescriptor, getDescriptor, getDescriptor, getDescriptor, getDescriptor, getDescriptor, getMarshalAttributeGroup, getNamespaceSeparator, getNoNamespaceSchemaLocation, getSchema, getSchemaLocation, getTransformer, getValueWrapper, getXmlHeader, isApplicationJSON, isApplicationXML, isFragment, isIncludeRoot, isLogPayload, isMarshalEmptyCollections, isReduceAnyArrays, isSimpleXMLRoot, isWrapperAsCollectionName, marshal, marshal, marshal, marshal, marshal, marshal, marshal, objectToXML, objectToXMLNode, setAttachmentMarshaller, setAttributePrefix, setEncoding, setFormattedOutput, setFragment, setIncludeRoot, setLogPayload, setMarshalAttributeGroup, setMarshalEmptyCollections, setNamespaceSeparator, setNoNamespaceSchemaLocation, setReduceAnyArrays, setSchema, setSchemaLocation, setValueWrapper, setWrapperAsCollectionName, setXmlHeader
Methods inherited from class org.eclipse.persistence.internal.oxm.Marshaller
getContext, getEncoding, getErrorHandler, getIndentString, getProperty, isEqualUsingIdenity, isFormattedOutput, setEqualUsingIdenity, setErrorHandler, setIndentString
-
Constructor Details
-
XMLMarshaller
Create a new XMLMarshaller based on the specified session- Parameters:
xmlContext
- the XML content
-
XMLMarshaller
Copy constructor
-
-
Method Details
-
getXMLContext
Return the instance of XMLContext that was used to create this instance of XMLMarshaller. -
setXMLContext
Set the XMLContext used by this instance of XMLMarshaller. -
getProperties
Return a properties object for a given instance of the XMLMarshaller. -
setXMLMarshalHandler
-
marshal
PUBLIC: Convert the given object to XML and update the given result with that XML Document- Overrides:
marshal
in classXMLMarshaller<AbstractSession,
CharacterEscapeHandler, XMLContext, XMLDescriptor, XMLMarshalListener, MediaType, NamespacePrefixMapper, TreeObjectBuilder, DatabaseSession> - Parameters:
object
- the object to marshalresult
- the result to marshal the object to- Throws:
XMLMarshalException
- if an error occurred during marshalling
-
getNode
protected Node getNode(Object object, Node parentNode, AbstractSession session, XMLDescriptor xmlDescriptor, boolean isXMLRoot) -
getMarshalListener
- Overrides:
getMarshalListener
in classMarshaller<CharacterEscapeHandler,
XMLContext, XMLMarshalListener, MediaType, NamespacePrefixMapper>
-
setMarshalListener
- Overrides:
setMarshalListener
in classMarshaller<CharacterEscapeHandler,
XMLContext, XMLMarshalListener, MediaType, NamespacePrefixMapper>
-
marshal
Convert the given object to XML and update the given marshal record with that XML Document.- Parameters:
object
- the object to marshalmarshalRecord
- the marshalRecord to marshal the object to
-
objectToXML
protected Document objectToXML(Object object, XMLDescriptor descriptor, boolean isXMLRoot) throws XMLMarshalException INTERNAL: Convert the given object to an XML Document- Overrides:
objectToXML
in classXMLMarshaller<AbstractSession,
CharacterEscapeHandler, XMLContext, XMLDescriptor, XMLMarshalListener, MediaType, NamespacePrefixMapper, TreeObjectBuilder, DatabaseSession> - Parameters:
object
- the object to marshaldescriptor
- the XMLDescriptor for the object being marshalled- Returns:
- the document which the specified object has been marshalled to
- Throws:
XMLMarshalException
- if an error occurred during marshalling
-
objectToXMLNode
protected Node objectToXMLNode(Object object, Node rootNode, AbstractSession session, XMLDescriptor descriptor, boolean isXMLRoot) throws XMLMarshalException -
objectToXML
-
objectToXML
public Document objectToXML(Object object, XMLDescriptor descriptor, XMLRecord xmlRow, boolean isXMLRoot, DocumentPreservationPolicy docPresPolicy) INTERNAL: Convert the given object to an XML Document -
objectToXML
public Document objectToXML(Object object, Node rootNode, XMLDescriptor descriptor, XMLRecord xmlRow, boolean isXMLRoot, DocumentPreservationPolicy docPresPolicy) -
getDescriptor
-
clone
-
setNamespacePrefixMapper
NamespacePrefixMapper that can be used during marshal (instead of those set in the project meta data)- Overrides:
setNamespacePrefixMapper
in classMarshaller<CharacterEscapeHandler,
XMLContext, XMLMarshalListener, MediaType, NamespacePrefixMapper> - Since:
- 2.3.3
-
getNamespacePrefixMapper
NamespacePrefixMapper that can be used during marshal (instead of those set in the project meta data)- Overrides:
getNamespacePrefixMapper
in classMarshaller<CharacterEscapeHandler,
XMLContext, XMLMarshalListener, MediaType, NamespacePrefixMapper> - Since:
- 2.3.3
-
getCharacterEscapeHandler
Return this Marshaller's CharacterEscapeHandler.- Overrides:
getCharacterEscapeHandler
in classMarshaller<CharacterEscapeHandler,
XMLContext, XMLMarshalListener, MediaType, NamespacePrefixMapper> - Since:
- 2.3.3
-
setCharacterEscapeHandler
Set this Marshaller's CharacterEscapeHandler.- Overrides:
setCharacterEscapeHandler
in classMarshaller<CharacterEscapeHandler,
XMLContext, XMLMarshalListener, MediaType, NamespacePrefixMapper> - Since:
- 2.3.3
-
setMediaType
Set the MediaType for this xmlMarshaller. See org.eclipse.persistence.oxm.MediaType for the media types supported by EclipseLink MOXy- Overrides:
setMediaType
in classXMLMarshaller<AbstractSession,
CharacterEscapeHandler, XMLContext, XMLDescriptor, XMLMarshalListener, MediaType, NamespacePrefixMapper, TreeObjectBuilder, DatabaseSession> - Since:
- EclipseLink 2.4.0
-
getMediaType
Get the MediaType for this xmlMarshaller. See org.eclipse.persistence.oxm.MediaType for the media types supported by EclipseLink MOXy If not set the default is MediaType.APPLICATION_XML- Returns:
- MediaType
- Since:
- EclipseLink 2.4.0
-
getJsonTypeConfiguration
Returns json type configuration.- Specified by:
getJsonTypeConfiguration
in classMarshaller<CharacterEscapeHandler,
XMLContext, XMLMarshalListener, MediaType, NamespacePrefixMapper> - Returns:
- json type configuration
- Since:
- 2.6.0
-