Top Description Fields Constructors Methods
org.eclipse.persistence.oxm

public Class XMLMarshaller

extends XMLMarshaller<AbstractSession, CharacterEscapeHandler, XMLContext, XMLDescriptor, XMLMarshalListener, MediaType, NamespacePrefixMapper, TreeObjectBuilder, DatabaseSession>
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Imports
java.util.Collection, .Properties, javax.xml.transform.Result, javax.xml.transform.sax.SAXResult, org.eclipse.persistence.exceptions.XMLMarshalException, org.eclipse.persistence.internal.core.helper.CoreClassConstants, org.eclipse.persistence.internal.core.sessions.CoreAbstractSession, org.eclipse.persistence.internal.oxm.FragmentContentHandler, .JsonTypeConfiguration, .Root, .TreeObjectBuilder, .XMLObjectBuilder, .XPathEngine, org.eclipse.persistence.internal.oxm.record.ExtendedResult, org.eclipse.persistence.internal.security.PrivilegedAccessHelper, org.eclipse.persistence.internal.sessions.AbstractSession, org.eclipse.persistence.oxm.documentpreservation.DocumentPreservationPolicy, org.eclipse.persistence.oxm.record.MarshalRecord, .NodeRecord, .XMLRecord, org.eclipse.persistence.platform.xml.XMLPlatformException, org.eclipse.persistence.sessions.DatabaseSession, org.w3c.dom.Document, .Element, .Node

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.

See Also
org.eclipse.persistence.oxm.XMLContext

Field Summary

Modifier and TypeField and Description
private JsonTypeConfiguration
private Object
Inherited from org.eclipse.persistence.internal.oxm.XMLMarshaller:
attachmentMarshallerDEFAULT_XML_VERSIONdomToEventWriterClassdomToStreamWriterClassmediaTypestaxResultClassstaxResultGetEventWriterMethodstaxResultGetStreamWriterMethodtransformerwriteToEventWriterMethodwriteToStreamMethod

Constructor Summary

AccessConstructor and Description
public
XMLMarshaller(XMLContext
the XML content
xmlContext
)

Create a new XMLMarshaller based on the specified session

protected
XMLMarshaller(XMLMarshaller xmlMarshaller)

Copy constructor

Method Summary

Modifier and TypeMethod and Description
private void
public XMLMarshaller
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.
public CharacterEscapeHandler
protected XMLDescriptor
getDescriptor(Object object, AbstractSession session, boolean isXMLRoot)

public JsonTypeConfiguration

Returns:

json type configuration
getJsonTypeConfiguration
()

Implements abstract org.eclipse.persistence.internal.oxm.Marshaller.getJsonTypeConfiguration.

Returns json type configuration.
public XMLMarshalListener
public MediaType

Returns:

MediaType
getMediaType
()

Get the MediaType for this xmlMarshaller.

public NamespacePrefixMapper
getNamespacePrefixMapper()

Overrides org.eclipse.persistence.internal.oxm.Marshaller.getNamespacePrefixMapper.

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)

Overrides org.eclipse.persistence.internal.oxm.XMLMarshaller.getNode.

public Properties
getProperties()

Return a properties object for a given instance of the XMLMarshaller.

public XMLContext
getXMLContext()

Return the instance of XMLContext that was used to create this instance of XMLMarshaller.

public void
marshal(Object
the object to marshal
object
,
Result
the result to marshal the object to
result
)

Overrides org.eclipse.persistence.internal.oxm.XMLMarshaller.marshal.

PUBLIC: Convert the given object to XML and update the given result with that XML Document
protected void
marshal(Object
the object to marshal
object
,
AbstractSession session, MarshalRecord<MARSHALLER extends Marshaller>
the marshalRecord to marshal the object to
marshalRecord
)

Convert the given object to XML and update the given marshal record with that XML Document.

protected Document

Returns:

the document which the specified object has been marshalled to
objectToXML
(Object
the object to marshal
object
,
XMLDescriptor
the XMLDescriptor for the object being marshalled
descriptor
,
boolean isXMLRoot)

Overrides org.eclipse.persistence.internal.oxm.XMLMarshaller.objectToXML.

INTERNAL: Convert the given object to an XML Document
public Document
objectToXML(Object object, Node parent, DocumentPreservationPolicy docPresPolicy)

public Document
objectToXML(Object object, XMLDescriptor descriptor, XMLRecord xmlRow, boolean isXMLRoot, DocumentPreservationPolicy docPresPolicy)

INTERNAL: Convert the given object to an XML Document

public Document
objectToXML(Object object, Node rootNode, XMLDescriptor descriptor, XMLRecord xmlRow, boolean isXMLRoot, DocumentPreservationPolicy docPresPolicy)

protected Node
public void
public void
public void
setMediaType(MediaType mediaType)

Overrides org.eclipse.persistence.internal.oxm.XMLMarshaller.setMediaType.

Set the MediaType for this xmlMarshaller.
public void
setNamespacePrefixMapper(NamespacePrefixMapper mapper)

Overrides org.eclipse.persistence.internal.oxm.Marshaller.setNamespacePrefixMapper.

NamespacePrefixMapper that can be used during marshal (instead of those set in the project meta data)
public void
setXMLContext(XMLContext value)

Set the XMLContext used by this instance of XMLMarshaller.

public void
Inherited from org.eclipse.persistence.internal.oxm.XMLMarshaller:
addDescriptorNamespacesToXMLRecordcopyNamespacesgetAttachmentMarshallergetAttributePrefixgetDescriptorgetDescriptorgetDescriptorgetDescriptorgetDescriptorgetDescriptorgetMarshalAttributeGroupgetNamespaceSeparatorgetNoNamespaceSchemaLocationgetSchemagetSchemaLocationgetTransformergetValueWrappergetXmlHeaderisApplicationJSONisApplicationXMLisFragmentisIncludeRootisLogPayloadisMarshalEmptyCollectionsisReduceAnyArraysisSimpleXMLRootisWrapperAsCollectionNamemarshalmarshalmarshalmarshalmarshalmarshalmarshalobjectToXMLobjectToXMLNodesetAttachmentMarshallersetAttributePrefixsetEncodingsetFormattedOutputsetFragmentsetIncludeRootsetLogPayloadsetMarshalAttributeGroupsetMarshalEmptyCollectionssetNamespaceSeparatorsetNoNamespaceSchemaLocationsetReduceAnyArrayssetSchemasetSchemaLocationsetValueWrappersetWrapperAsCollectionNamesetXmlHeader

Field Detail

jsonTypeConfigurationback to summary
private JsonTypeConfiguration jsonTypeConfiguration
marshalAttributeGroupback to summary
private Object marshalAttributeGroup

Hides org.eclipse.persistence.internal.oxm.XMLMarshaller.marshalAttributeGroup.

Constructor Detail

XMLMarshallerback to summary
public XMLMarshaller(XMLContext xmlContext)

Create a new XMLMarshaller based on the specified session

Parameters
xmlContext:XMLContext

the XML content

XMLMarshallerback to summary
protected XMLMarshaller(XMLMarshaller xmlMarshaller)

Copy constructor

Method Detail

addSchemaLocationsback to summary
private void addSchemaLocations(Document document, AbstractSession session)
cloneback to summary
public XMLMarshaller clone()

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:XMLMarshaller

a clone of this instance.

Annotations
@Override
getCharacterEscapeHandlerback to summary
public CharacterEscapeHandler getCharacterEscapeHandler()

Overrides org.eclipse.persistence.internal.oxm.Marshaller.getCharacterEscapeHandler.

Return this Marshaller's CharacterEscapeHandler.

Annotations
@Override
Since
2.3.3
getDescriptorback to summary
protected XMLDescriptor getDescriptor(Object object, AbstractSession session, boolean isXMLRoot)
getJsonTypeConfigurationback to summary
public JsonTypeConfiguration getJsonTypeConfiguration()

Implements abstract org.eclipse.persistence.internal.oxm.Marshaller.getJsonTypeConfiguration.

Returns json type configuration.

Returns:JsonTypeConfiguration

json type configuration

Annotations
@Override
Since
2.6.0
getMarshalListenerback to summary
public XMLMarshalListener getMarshalListener()

Overrides org.eclipse.persistence.internal.oxm.Marshaller.getMarshalListener.

Annotations
@Override
getMediaTypeback to summary
public MediaType 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

MediaType

Since
EclipseLink 2.4.0
getNamespacePrefixMapperback to summary
public NamespacePrefixMapper getNamespacePrefixMapper()

Overrides org.eclipse.persistence.internal.oxm.Marshaller.getNamespacePrefixMapper.

NamespacePrefixMapper that can be used during marshal (instead of those set in the project meta data)

Annotations
@Override
Since
2.3.3
getNodeback to summary
protected Node getNode(Object object, Node parentNode, AbstractSession session, XMLDescriptor xmlDescriptor, boolean isXMLRoot)

Overrides org.eclipse.persistence.internal.oxm.XMLMarshaller.getNode.

Annotations
@Override
getPropertiesback to summary
public Properties getProperties()

Return a properties object for a given instance of the XMLMarshaller.

getXMLContextback to summary
public XMLContext getXMLContext()

Return the instance of XMLContext that was used to create this instance of XMLMarshaller.

marshalback to summary
public void marshal(Object object, Result result) throws XMLMarshalException

Overrides org.eclipse.persistence.internal.oxm.XMLMarshaller.marshal.

PUBLIC: Convert the given object to XML and update the given result with that XML Document

Parameters
object:Object

the object to marshal

result:Result

the result to marshal the object to

Annotations
@Override
Exceptions
XMLMarshalException:
if an error occurred during marshalling
marshalback to summary
protected void marshal(Object object, AbstractSession session, MarshalRecord<MARSHALLER extends Marshaller> marshalRecord)

Convert the given object to XML and update the given marshal record with that XML Document.

Parameters
object:Object

the object to marshal

marshalRecord:MarshalRecord<MARSHALLER extends Marshaller>

the marshalRecord to marshal the object to

objectToXMLback to summary
protected Document objectToXML(Object object, XMLDescriptor descriptor, boolean isXMLRoot) throws XMLMarshalException

Overrides org.eclipse.persistence.internal.oxm.XMLMarshaller.objectToXML.

INTERNAL: Convert the given object to an XML Document

Parameters
object:Object

the object to marshal

descriptor:XMLDescriptor

the XMLDescriptor for the object being marshalled

Returns:Document

the document which the specified object has been marshalled to

Annotations
@Override
Exceptions
XMLMarshalException:
if an error occurred during marshalling
objectToXMLback to summary
public Document objectToXML(Object object, Node parent, DocumentPreservationPolicy docPresPolicy)
objectToXMLback to summary
public Document objectToXML(Object object, XMLDescriptor descriptor, XMLRecord xmlRow, boolean isXMLRoot, DocumentPreservationPolicy docPresPolicy)

INTERNAL: Convert the given object to an XML Document

objectToXMLback to summary
public Document objectToXML(Object object, Node rootNode, XMLDescriptor descriptor, XMLRecord xmlRow, boolean isXMLRoot, DocumentPreservationPolicy docPresPolicy)
objectToXMLNodeback to summary
protected Node objectToXMLNode(Object object, Node rootNode, AbstractSession session, XMLDescriptor descriptor, boolean isXMLRoot) throws XMLMarshalException

Overrides org.eclipse.persistence.internal.oxm.XMLMarshaller.objectToXMLNode.

Annotations
@Override
setCharacterEscapeHandlerback to summary
public void setCharacterEscapeHandler(CharacterEscapeHandler c)

Overrides org.eclipse.persistence.internal.oxm.Marshaller.setCharacterEscapeHandler.

Set this Marshaller's CharacterEscapeHandler.

Annotations
@Override
Since
2.3.3
setMarshalListenerback to summary
public void setMarshalListener(XMLMarshalListener listener)

Overrides org.eclipse.persistence.internal.oxm.Marshaller.setMarshalListener.

Annotations
@Override
setMediaTypeback to summary
public void setMediaType(MediaType mediaType)

Overrides org.eclipse.persistence.internal.oxm.XMLMarshaller.setMediaType.

Set the MediaType for this xmlMarshaller. See org.eclipse.persistence.oxm.MediaType for the media types supported by EclipseLink MOXy

Annotations
@Override
Since
EclipseLink 2.4.0
setNamespacePrefixMapperback to summary
public void setNamespacePrefixMapper(NamespacePrefixMapper mapper)

Overrides org.eclipse.persistence.internal.oxm.Marshaller.setNamespacePrefixMapper.

NamespacePrefixMapper that can be used during marshal (instead of those set in the project meta data)

Annotations
@Override
Since
2.3.3
setXMLContextback to summary
public void setXMLContext(XMLContext value)

Set the XMLContext used by this instance of XMLMarshaller.

setXMLMarshalHandlerback to summary
public void setXMLMarshalHandler(XMLMarshalListener marshalListener)