Module org.eclipse.persistence.core
Class XMLMarshaller<ABSTRACT_SESSION extends CoreAbstractSession,CHARACTER_ESCAPE_HANDLER extends CharacterEscapeHandler,CONTEXT extends Context<ABSTRACT_SESSION,DESCRIPTOR,?,?,?,SESSION,?>,DESCRIPTOR extends Descriptor<?,?,?,?,?,?,?,?,?,?>,MARSHALLER_LISTENER extends Marshaller.Listener,MEDIA_TYPE extends MediaType,NAMESPACE_PREFIX_MAPPER extends NamespacePrefixMapper,OBJECT_BUILDER extends ObjectBuilder<?,ABSTRACT_SESSION,?,XMLMarshaller>,SESSION extends CoreSession>
java.lang.Object
org.eclipse.persistence.internal.oxm.Marshaller<CHARACTER_ESCAPE_HANDLER,CONTEXT,MARSHALLER_LISTENER,MEDIA_TYPE,NAMESPACE_PREFIX_MAPPER>
org.eclipse.persistence.internal.oxm.XMLMarshaller<ABSTRACT_SESSION,CHARACTER_ESCAPE_HANDLER,CONTEXT,DESCRIPTOR,MARSHALLER_LISTENER,MEDIA_TYPE,NAMESPACE_PREFIX_MAPPER,OBJECT_BUILDER,SESSION>
- Direct Known Subclasses:
XMLMarshaller
public abstract class XMLMarshaller<ABSTRACT_SESSION extends CoreAbstractSession,CHARACTER_ESCAPE_HANDLER extends CharacterEscapeHandler,CONTEXT extends Context<ABSTRACT_SESSION,DESCRIPTOR,?,?,?,SESSION,?>,DESCRIPTOR extends Descriptor<?,?,?,?,?,?,?,?,?,?>,MARSHALLER_LISTENER extends Marshaller.Listener,MEDIA_TYPE extends MediaType,NAMESPACE_PREFIX_MAPPER extends NamespacePrefixMapper,OBJECT_BUILDER extends ObjectBuilder<?,ABSTRACT_SESSION,?,XMLMarshaller>,SESSION extends CoreSession>
extends Marshaller<CHARACTER_ESCAPE_HANDLER,CONTEXT,MARSHALLER_LISTENER,MEDIA_TYPE,NAMESPACE_PREFIX_MAPPER>
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.persistence.internal.oxm.Marshaller
Marshaller.Listener
-
Field Summary
Modifier and TypeFieldDescriptionprotected XMLAttachmentMarshaller
protected static final String
protected static Class
<?> protected static Class
<?> protected MEDIA_TYPE
protected static Class
<?> protected static Method
protected static Method
protected XMLTransformer
protected static Method
protected static Method
Fields inherited from class org.eclipse.persistence.internal.oxm.Marshaller
context, mapper, marshalProperties
-
Constructor Summary
ModifierConstructorDescriptionprotected
XMLMarshaller
(CONTEXT context) protected
XMLMarshaller
(XMLMarshaller xmlMarshaller) Copy constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addDescriptorNamespacesToXMLRecord
(DESCRIPTOR xmlDescriptor, AbstractMarshalRecord record) protected void
copyNamespaces
(NamespaceResolver source, NamespaceResolver target) Value that will be used to prefix attributes.protected DESCRIPTOR
getDescriptor
(Class<?> clazz, ABSTRACT_SESSION session) INTERNAL: Return the descriptor for the root object.getDescriptor
(Object object) INTERNAL: Return the descriptor for the root object.protected DESCRIPTOR
getDescriptor
(Object object, boolean isXMLRoot) protected DESCRIPTOR
getDescriptor
(Object object, ABSTRACT_SESSION session) INTERNAL: Return the descriptor for the root object.protected DESCRIPTOR
getDescriptor
(Root object) protected DESCRIPTOR
getDescriptor
(Root object, ABSTRACT_SESSION session) char
Get the namespace separator used during marshal operations.protected Node
getNode
(Object object, Node parentNode, ABSTRACT_SESSION session, DESCRIPTOR descriptor, boolean isRoot) Get the no namespace schema location set on this XMLMarshallerGet the schema location set on this XMLMarshallerINTERNALName of the property to marshal/unmarshal as a wrapper on the text() mappings Ignored marshalling XML.Get this Marshaller's XML Header.boolean
INTERNALboolean
INTERNALboolean
PUBLIC: Returns if this should marshal to a fragment.boolean
Determine if the @XMLRootElement should be marshalled when present.boolean
Name of the property to determine if empty collections should be marshalled as [] Ignored marshalling XML.boolean
Property to determine if size 1 any collections should be treated as collections Ignored marshalling XML.protected boolean
isSimpleXMLRoot
(Root xmlRoot) boolean
void
marshal
(Object object, OutputStream outputStream) PUBLIC: Convert the given object to XML and update the given outputStream with that XML Documentvoid
PUBLIC: Convert the given object to XML and update the given writer with that XML Documentvoid
PUBLIC: Convert the given object to XML and update the given result with that XML Documentvoid
marshal
(Object object, MarshalRecord marshalRecord) Convert the given object to XML and update the given marshal record with that XML Document.protected void
marshal
(Object object, MarshalRecord marshalRecord, ABSTRACT_SESSION session, DESCRIPTOR descriptor, boolean isXMLRoot) Convert the given object to XML and update the given marshal record with that XML Document.void
PUBLIC:void
marshal
(Object object, ContentHandler contentHandler) PUBLIC: Convert the given object to XML and update the given contentHandler with that XML Documentvoid
marshal
(Object object, ContentHandler contentHandler, LexicalHandler lexicalHandler) PUBLIC: Convert the given object to XML and update the given contentHandler with that XML DocumentobjectToXML
(Object object) PUBLIC: Convert the given object to an XML Documentprotected Document
objectToXML
(Object object, DESCRIPTOR descriptor, boolean isXMLRoot) INTERNAL: Convert the given object to an XML Documentprotected Node
objectToXMLNode
(Object object, ABSTRACT_SESSION session, DESCRIPTOR descriptor, boolean isXMLRoot) INTERNAL: Like ObjectToXML but is may also return a document fragment instead of a document in the case of a non-root object.protected Node
objectToXMLNode
(Object object, Node rootNode, ABSTRACT_SESSION session, DESCRIPTOR descriptor, boolean isXMLRoot) void
void
setAttributePrefix
(String attributePrefix) Value that will be used to prefix attributes.void
setEncoding
(String newEncoding) Set the encoding on this XMLMarshaller If the encoding is not set the default UTF-8 will be usedvoid
setFormattedOutput
(boolean shouldFormat) Set if this XMLMarshaller should format the XML By default this is set to true and the XML marshalled will be formatted.void
setFragment
(boolean fragment) PUBLIC: Set if this should marshal to a fragment.void
setIncludeRoot
(boolean includeRoot) Determine if the@XMLRootElement
should be marshalled when present.void
setLogPayload
(Boolean logPayload) void
setMarshalAttributeGroup
(Object group) void
setMarshalEmptyCollections
(Boolean marshalEmptyCollections) Name of the property to determine if empty collections should be marshalled as [] Ignored marshalling XML.void
setMediaType
(MEDIA_TYPE mediaType) Set the MediaType for this xmlMarshaller.void
setNamespaceSeparator
(char namespaceSeparator) Set the namespace separator used during marshal operations.void
setNoNamespaceSchemaLocation
(String newNoNamespaceSchemaLocation) Set the no namespace schema location on this XMLMarshallervoid
setReduceAnyArrays
(boolean reduceAnyArrays) Property to determine if size 1 any collections should be treated as collections Ignored marshalling XML.void
void
setSchemaLocation
(String newSchemaLocation) Set the schema location on this XMLMarshallervoid
setValueWrapper
(String valueWrapper) Name of the property to marshal/unmarshal as a wrapper on the text() mappings Ignored marshalling XML.void
setWrapperAsCollectionName
(boolean wrapperAsCollectionName) void
setXmlHeader
(String xmlHeader) Set this Marshaller's XML Header.Methods inherited from class org.eclipse.persistence.internal.oxm.Marshaller
getCharacterEscapeHandler, getContext, getEncoding, getErrorHandler, getIndentString, getJsonTypeConfiguration, getMarshalListener, getNamespacePrefixMapper, getProperty, isEqualUsingIdenity, isFormattedOutput, setCharacterEscapeHandler, setEqualUsingIdenity, setErrorHandler, setIndentString, setMarshalListener, setNamespacePrefixMapper
-
Field Details
-
DEFAULT_XML_VERSION
- See Also:
-
staxResultClass
-
staxResultGetStreamWriterMethod
-
staxResultGetEventWriterMethod
-
writeToStreamMethod
-
writeToEventWriterMethod
-
domToStreamWriterClass
-
domToEventWriterClass
-
attachmentMarshaller
-
mediaType
-
transformer
-
-
Constructor Details
-
XMLMarshaller
-
XMLMarshaller
Copy constructor
-
-
Method Details
-
addDescriptorNamespacesToXMLRecord
protected void addDescriptorNamespacesToXMLRecord(DESCRIPTOR xmlDescriptor, AbstractMarshalRecord record) -
copyNamespaces
-
getAttachmentMarshaller
- Specified by:
getAttachmentMarshaller
in classMarshaller<CHARACTER_ESCAPE_HANDLER extends CharacterEscapeHandler,
CONTEXT extends Context<ABSTRACT_SESSION, DESCRIPTOR, ?, ?, ?, SESSION, ?>, MARSHALLER_LISTENER extends Marshaller.Listener, MEDIA_TYPE extends MediaType, NAMESPACE_PREFIX_MAPPER extends NamespacePrefixMapper>
-
getAttributePrefix
Value that will be used to prefix attributes. Ignored marshalling XML.- Since:
- 2.4
-
getDescriptor
protected DESCRIPTOR getDescriptor(Class<?> clazz, ABSTRACT_SESSION session) throws XMLMarshalException INTERNAL: Return the descriptor for the root object.- Throws:
XMLMarshalException
-
getDescriptor
INTERNAL: Return the descriptor for the root object.- Throws:
XMLMarshalException
-
getDescriptor
protected DESCRIPTOR getDescriptor(Object object, ABSTRACT_SESSION session) throws XMLMarshalException INTERNAL: Return the descriptor for the root object.- Throws:
XMLMarshalException
-
getDescriptor
-
getDescriptor
- Throws:
XMLMarshalException
-
getDescriptor
protected DESCRIPTOR getDescriptor(Root object, ABSTRACT_SESSION session) throws XMLMarshalException - Throws:
XMLMarshalException
-
getNode
protected Node getNode(Object object, Node parentNode, ABSTRACT_SESSION session, DESCRIPTOR descriptor, boolean isRoot) -
getNoNamespaceSchemaLocation
Get the no namespace schema location set on this XMLMarshaller- Returns:
- the no namespace schema location specified on this XMLMarshaller
-
getSchema
-
getTransformer
INTERNAL- Specified by:
getTransformer
in classMarshaller<CHARACTER_ESCAPE_HANDLER extends CharacterEscapeHandler,
CONTEXT extends Context<ABSTRACT_SESSION, DESCRIPTOR, ?, ?, ?, SESSION, ?>, MARSHALLER_LISTENER extends Marshaller.Listener, MEDIA_TYPE extends MediaType, NAMESPACE_PREFIX_MAPPER extends NamespacePrefixMapper> - Returns:
- the transformer instance for this marshaller
-
getValueWrapper
Name of the property to marshal/unmarshal as a wrapper on the text() mappings Ignored marshalling XML.- Since:
- 2.4
-
getXmlHeader
Get this Marshaller's XML Header.- Since:
- 2.4
-
getSchemaLocation
Get the schema location set on this XMLMarshaller- Returns:
- the schema location specified on this XMLMarshaller
-
isApplicationJSON
public boolean isApplicationJSON()INTERNAL- Specified by:
isApplicationJSON
in classMarshaller<CHARACTER_ESCAPE_HANDLER extends CharacterEscapeHandler,
CONTEXT extends Context<ABSTRACT_SESSION, DESCRIPTOR, ?, ?, ?, SESSION, ?>, MARSHALLER_LISTENER extends Marshaller.Listener, MEDIA_TYPE extends MediaType, NAMESPACE_PREFIX_MAPPER extends NamespacePrefixMapper> - Returns:
- true if the media type is application/json, else false.
- Since:
- EclipseLink 2.6.0
-
isApplicationXML
public boolean isApplicationXML()INTERNAL- Specified by:
isApplicationXML
in classMarshaller<CHARACTER_ESCAPE_HANDLER extends CharacterEscapeHandler,
CONTEXT extends Context<ABSTRACT_SESSION, DESCRIPTOR, ?, ?, ?, SESSION, ?>, MARSHALLER_LISTENER extends Marshaller.Listener, MEDIA_TYPE extends MediaType, NAMESPACE_PREFIX_MAPPER extends NamespacePrefixMapper> - Returns:
- true if the media type is application/xml, else false.
- Since:
- EclipseLink 2.6.0
-
isFragment
public boolean isFragment()PUBLIC: Returns if this should marshal to a fragment. If true an XML header string is not written out.- Returns:
- if this should marshal to a fragment or not
-
isIncludeRoot
public boolean isIncludeRoot()Determine if the @XMLRootElement should be marshalled when present. Ignored marshalling XML.- Specified by:
isIncludeRoot
in classMarshaller<CHARACTER_ESCAPE_HANDLER extends CharacterEscapeHandler,
CONTEXT extends Context<ABSTRACT_SESSION, DESCRIPTOR, ?, ?, ?, SESSION, ?>, MARSHALLER_LISTENER extends Marshaller.Listener, MEDIA_TYPE extends MediaType, NAMESPACE_PREFIX_MAPPER extends NamespacePrefixMapper> - Since:
- 2.4
-
isReduceAnyArrays
public boolean isReduceAnyArrays()Property to determine if size 1 any collections should be treated as collections Ignored marshalling XML.- Specified by:
isReduceAnyArrays
in classMarshaller<CHARACTER_ESCAPE_HANDLER extends CharacterEscapeHandler,
CONTEXT extends Context<ABSTRACT_SESSION, DESCRIPTOR, ?, ?, ?, SESSION, ?>, MARSHALLER_LISTENER extends Marshaller.Listener, MEDIA_TYPE extends MediaType, NAMESPACE_PREFIX_MAPPER extends NamespacePrefixMapper>
-
getNamespaceSeparator
public char getNamespaceSeparator()Get the namespace separator used during marshal operations. If mediaType is application/json '.' is the default Ignored marshalling XML.- Since:
- 2.4
-
isMarshalEmptyCollections
public boolean isMarshalEmptyCollections()Name of the property to determine if empty collections should be marshalled as [] Ignored marshalling XML.- Since:
- 2.4
-
isWrapperAsCollectionName
public boolean isWrapperAsCollectionName()- Specified by:
isWrapperAsCollectionName
in classMarshaller<CHARACTER_ESCAPE_HANDLER extends CharacterEscapeHandler,
CONTEXT extends Context<ABSTRACT_SESSION, DESCRIPTOR, ?, ?, ?, SESSION, ?>, MARSHALLER_LISTENER extends Marshaller.Listener, MEDIA_TYPE extends MediaType, NAMESPACE_PREFIX_MAPPER extends NamespacePrefixMapper>
-
isSimpleXMLRoot
-
marshal
PUBLIC: Convert the given object to XML and update the given contentHandler with that XML Document- Parameters:
object
- the object to marshalcontentHandler
- the contentHandler which the specified object should be marshalled to- Throws:
XMLMarshalException
- if an error occurred during marshalling
-
marshal
public void marshal(Object object, ContentHandler contentHandler, LexicalHandler lexicalHandler) throws XMLMarshalException PUBLIC: Convert the given object to XML and update the given contentHandler with that XML Document- Parameters:
object
- the object to marshalcontentHandler
- the contentHandler which the specified object should be marshalled to- Throws:
XMLMarshalException
- if an error occurred during marshalling
-
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
-
marshal
protected void marshal(Object object, MarshalRecord marshalRecord, ABSTRACT_SESSION session, DESCRIPTOR descriptor, boolean isXMLRoot) 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 todescriptor
- the XMLDescriptor for the object being marshalled
-
marshal
PUBLIC:- Parameters:
object
- the object to marshalnode
- the node which the specified object should be marshalled to- Throws:
XMLMarshalException
- if an error occurred during marshalling
-
marshal
PUBLIC: Convert the given object to XML and update the given outputStream with that XML Document- Parameters:
object
- the object to marshaloutputStream
- the outputStream to marshal the object to- Throws:
XMLMarshalException
- if an error occurred during marshalling
-
marshal
PUBLIC: Convert the given object to XML and update the given result with that XML Document- Parameters:
object
- the object to marshalresult
- the result to marshal the object to- Throws:
XMLMarshalException
- if an error occurred during marshalling
-
marshal
PUBLIC: Convert the given object to XML and update the given writer with that XML Document- Parameters:
object
- the object to marshalwriter
- the writer to marshal the object to- Throws:
XMLMarshalException
- if an error occurred during marshalling
-
objectToXML
PUBLIC: Convert the given object to an XML Document- Parameters:
object
- the object to marshal- Returns:
- the document which the specified object has been marshalled to
- Throws:
XMLMarshalException
- if an error occurred during marshalling
-
objectToXML
protected Document objectToXML(Object object, DESCRIPTOR descriptor, boolean isXMLRoot) throws XMLMarshalException INTERNAL: Convert the given object to an XML Document- 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, ABSTRACT_SESSION session, DESCRIPTOR descriptor, boolean isXMLRoot) throws XMLMarshalException INTERNAL: Like ObjectToXML but is may also return a document fragment instead of a document in the case of a non-root object.- Throws:
XMLMarshalException
-
objectToXMLNode
protected Node objectToXMLNode(Object object, Node rootNode, ABSTRACT_SESSION session, DESCRIPTOR descriptor, boolean isXMLRoot) throws XMLMarshalException - Throws:
XMLMarshalException
-
setAttachmentMarshaller
-
setAttributePrefix
Value that will be used to prefix attributes. Ignored marshalling XML.- Since:
- 2.4
-
setEncoding
Set the encoding on this XMLMarshaller If the encoding is not set the default UTF-8 will be used- Overrides:
setEncoding
in classMarshaller<CHARACTER_ESCAPE_HANDLER extends CharacterEscapeHandler,
CONTEXT extends Context<ABSTRACT_SESSION, DESCRIPTOR, ?, ?, ?, SESSION, ?>, MARSHALLER_LISTENER extends Marshaller.Listener, MEDIA_TYPE extends MediaType, NAMESPACE_PREFIX_MAPPER extends NamespacePrefixMapper> - Parameters:
newEncoding
- the encoding to set on this XMLMarshaller
-
setFormattedOutput
public void setFormattedOutput(boolean shouldFormat) Set if this XMLMarshaller should format the XML By default this is set to true and the XML marshalled will be formatted.- Overrides:
setFormattedOutput
in classMarshaller<CHARACTER_ESCAPE_HANDLER extends CharacterEscapeHandler,
CONTEXT extends Context<ABSTRACT_SESSION, DESCRIPTOR, ?, ?, ?, SESSION, ?>, MARSHALLER_LISTENER extends Marshaller.Listener, MEDIA_TYPE extends MediaType, NAMESPACE_PREFIX_MAPPER extends NamespacePrefixMapper> - Parameters:
shouldFormat
- if this XMLMarshaller should format the XML
-
setFragment
public void setFragment(boolean fragment) PUBLIC: Set if this should marshal to a fragment. If true an XML header string is not written out.- Parameters:
fragment
- if this should marshal to a fragment or not
-
setIncludeRoot
public void setIncludeRoot(boolean includeRoot) Determine if the@XMLRootElement
should be marshalled when present. Ignored marshalling XML.- Since:
- 2.4
-
setMarshalEmptyCollections
Name of the property to determine if empty collections should be marshalled as [] Ignored marshalling XML.- Since:
- 2.4
-
setMediaType
Set the MediaType for this xmlMarshaller. See org.eclipse.persistence.oxm.MediaType for the media types supported by EclipseLink MOXy -
setNamespaceSeparator
public void setNamespaceSeparator(char namespaceSeparator) Set the namespace separator used during marshal operations. If mediaType is application/json '.' is the default Ignored marshalling XML.- Since:
- 2.4
-
setNoNamespaceSchemaLocation
Set the no namespace schema location on this XMLMarshaller- Parameters:
newNoNamespaceSchemaLocation
- no namespace schema location to be seton this XMLMarshaller
-
setReduceAnyArrays
public void setReduceAnyArrays(boolean reduceAnyArrays) Property to determine if size 1 any collections should be treated as collections Ignored marshalling XML. -
setSchema
-
setSchemaLocation
Set the schema location on this XMLMarshaller- Parameters:
newSchemaLocation
- the schema location to be seton this XMLMarshaller
-
setWrapperAsCollectionName
public void setWrapperAsCollectionName(boolean wrapperAsCollectionName) -
setValueWrapper
Name of the property to marshal/unmarshal as a wrapper on the text() mappings Ignored marshalling XML.- Since:
- 2.4
-
setXmlHeader
Set this Marshaller's XML Header. This header string will appear after the XML processing instruction (<?xml ...>), but before the start of the document's data.
This feature is only supported when marshalling to Stream, Writer, or StreamResult.
- Since:
- 2.4
-
setMarshalAttributeGroup
-
getMarshalAttributeGroup
-
isLogPayload
-
setLogPayload
-