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
FieldsModifier and TypeFieldDescriptionprotected XMLAttachmentMarshallerprotected static final Stringprotected static Class<?> protected static Class<?> protected MEDIA_TYPEprotected static Class<?> protected static Methodprotected static Methodprotected XMLTransformerprotected static Methodprotected static MethodFields inherited from class org.eclipse.persistence.internal.oxm.Marshaller
context, mapper, marshalProperties -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedXMLMarshaller(CONTEXT context) protectedXMLMarshaller(XMLMarshaller xmlMarshaller) Copy constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddDescriptorNamespacesToXMLRecord(DESCRIPTOR xmlDescriptor, AbstractMarshalRecord record) protected voidcopyNamespaces(NamespaceResolver source, NamespaceResolver target) Value that will be used to prefix attributes.protected DESCRIPTORgetDescriptor(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 DESCRIPTORgetDescriptor(Object object, boolean isXMLRoot) protected DESCRIPTORgetDescriptor(Object object, ABSTRACT_SESSION session) INTERNAL: Return the descriptor for the root object.protected DESCRIPTORgetDescriptor(Root object) protected DESCRIPTORgetDescriptor(Root object, ABSTRACT_SESSION session) charGet the namespace separator used during marshal operations.protected NodegetNode(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.booleanINTERNALbooleanINTERNALbooleanPUBLIC: Returns if this should marshal to a fragment.booleanDetermine if the @XMLRootElement should be marshalled when present.booleanName of the property to determine if empty collections should be marshalled as [] Ignored marshalling XML.booleanProperty to determine if size 1 any collections should be treated as collections Ignored marshalling XML.protected booleanisSimpleXMLRoot(Root xmlRoot) booleanvoidmarshal(Object object, OutputStream outputStream) PUBLIC: Convert the given object to XML and update the given outputStream with that XML DocumentvoidPUBLIC: Convert the given object to XML and update the given writer with that XML DocumentvoidPUBLIC: Convert the given object to XML and update the given result with that XML Documentvoidmarshal(Object object, MarshalRecord marshalRecord) Convert the given object to XML and update the given marshal record with that XML Document.protected voidmarshal(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.voidPUBLIC:voidmarshal(Object object, ContentHandler contentHandler) PUBLIC: Convert the given object to XML and update the given contentHandler with that XML Documentvoidmarshal(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 DocumentobjectToXML(Object object, DESCRIPTOR descriptor, boolean isXMLRoot) INTERNAL: Convert the given object to an XML Documentprotected NodeobjectToXMLNode(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 NodeobjectToXMLNode(Object object, Node rootNode, ABSTRACT_SESSION session, DESCRIPTOR descriptor, boolean isXMLRoot) voidvoidsetAttributePrefix(String attributePrefix) Value that will be used to prefix attributes.voidsetEncoding(String newEncoding) Set the encoding on this XMLMarshaller If the encoding is not set the default UTF-8 will be usedvoidsetFormattedOutput(boolean shouldFormat) Set if this XMLMarshaller should format the XML By default this is set to true and the XML marshalled will be formatted.voidsetFragment(boolean fragment) PUBLIC: Set if this should marshal to a fragment.voidsetIncludeRoot(boolean includeRoot) Determine if the@XMLRootElementshould be marshalled when present.voidsetLogPayload(Boolean logPayload) voidsetMarshalAttributeGroup(Object group) voidsetMarshalEmptyCollections(Boolean marshalEmptyCollections) Name of the property to determine if empty collections should be marshalled as [] Ignored marshalling XML.voidsetMediaType(MEDIA_TYPE mediaType) Set the MediaType for this xmlMarshaller.voidsetNamespaceSeparator(char namespaceSeparator) Set the namespace separator used during marshal operations.voidsetNoNamespaceSchemaLocation(String newNoNamespaceSchemaLocation) Set the no namespace schema location on this XMLMarshallervoidsetReduceAnyArrays(boolean reduceAnyArrays) Property to determine if size 1 any collections should be treated as collections Ignored marshalling XML.voidvoidsetSchemaLocation(String newSchemaLocation) Set the schema location on this XMLMarshallervoidsetValueWrapper(String valueWrapper) Name of the property to marshal/unmarshal as a wrapper on the text() mappings Ignored marshalling XML.voidsetWrapperAsCollectionName(boolean wrapperAsCollectionName) voidsetXmlHeader(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:
getAttachmentMarshallerin 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:
getTransformerin 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:
isApplicationJSONin 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:
isApplicationXMLin 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:
isIncludeRootin 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:
isReduceAnyArraysin 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:
isWrapperAsCollectionNamein 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:
setEncodingin 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:
setFormattedOutputin 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@XMLRootElementshould 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
-