Module org.eclipse.persistence.core
Class MarshalRecord<MARSHALLER extends Marshaller>
java.lang.Object
org.eclipse.persistence.internal.core.sessions.CoreAbstractRecord
org.eclipse.persistence.internal.oxm.record.AbstractMarshalRecordImpl<CoreAbstractSession,CoreField,MARSHALLER,NamespaceResolver>
org.eclipse.persistence.oxm.record.MarshalRecord<MARSHALLER>
- All Implemented Interfaces:
AbstractMarshalRecord<CoreAbstractSession,
,CoreField, MARSHALLER, NamespaceResolver> MarshalRecord<CoreAbstractSession,
,CoreField, MARSHALLER, NamespaceResolver> XMLRecord<CoreAbstractSession>
- Direct Known Subclasses:
ContentHandlerRecord
,JsonRecord
,JSONWriterRecord
,NodeRecord
,OutputStreamRecord
,ValidatingMarshalRecord
,WriterRecord
,XMLEventWriterRecord
,XMLStreamWriterRecord
public abstract class MarshalRecord<MARSHALLER extends Marshaller>
extends AbstractMarshalRecordImpl<CoreAbstractSession,CoreField,MARSHALLER,NamespaceResolver>
implements MarshalRecord<CoreAbstractSession,CoreField,MARSHALLER,NamespaceResolver>
A MarshalRecord encapsulates the marshal target.
MarshalRecords are stateful and state changes are triggered by different event notifications, therefore this class is not thread safe.
XML document creation will differ depending on the subclass of MarshalRecord used. For example when NodeRecord is used a child element is created on the openStartElement event, and when the ContentHandlerRecord is used a child element is not created until the closeStartMethod event.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.persistence.internal.oxm.record.MarshalRecord
MarshalRecord.CycleDetectionStack<E>
Nested classes/interfaces inherited from interface org.eclipse.persistence.internal.oxm.record.XMLRecord
XMLRecord.Nil
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
protected XPathFragment
protected static final String
Fields inherited from class org.eclipse.persistence.internal.oxm.record.AbstractMarshalRecordImpl
equalNamespaceResolvers, hasCustomNamespaceMapper, marshaller, namespaceAware, namespaceResolver, session
Fields inherited from interface org.eclipse.persistence.internal.oxm.record.XMLRecord
DEFAULT_ATTRIBUTE_GROUP, NIL
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
INTERNAL: Add the field-value pair to the document.void
addGroupingElement
(XPathNode xPathNode) INTERNAL: If an XPathNode does not have an associated NodeValue then add it to the MarshalRecord as a grouping element.protected void
addPositionalNodes
(XPathFragment xPathFragment, NamespaceResolver namespaceResolver) void
afterContainmentMarshal
(Object parent, Object child) abstract void
Receive notification of an attribute.void
attribute
(XPathFragment xPathFragment, NamespaceResolver namespaceResolver, Object value, QName schemaType) Convert the value if necessary and write out the attribute and converted value.abstract void
attribute
(XPathFragment xPathFragment, NamespaceResolver namespaceResolver, String value) Receive notification of an attribute.void
beforeContainmentMarshal
(Object child) abstract void
Receive notification of character data to be wrapped in a CDATA node.abstract void
characters
(String value) Receive notification of character data.void
characters
(QName schemaType, Object value, String mimeType, boolean isCDATA) Convert the value if necessary and write out the converted value.void
clear()
abstract void
Receive notification that all of the attribute events have occurred for the most recent element that has been started.void
closeStartGroupingElements
(XPathFragment groupingFragment) void
defaultNamespaceDeclaration
(String defaultNamespace) Add the defaultNamespace declarationabstract void
element
(XPathFragment frag) Receive notification of an element.void
emptyAttribute
(XPathFragment xPathFragment, NamespaceResolver namespaceResolver) Used when an nil attribute should be writtenboolean
emptyCollection
(XPathFragment xPathFragment, NamespaceResolver namespaceResolver, boolean openGrouping) Handle marshal of an empty collection.void
emptyComplex
(XPathFragment xPathFragment, NamespaceResolver namespaceResolver) Used when an nil attribute should be writtenvoid
emptySimple
(NamespaceResolver namespaceResolver) Used when an nil attribute should be writtenvoid
This method is used to inform the MarshalRecord that it is done receiving element events that are part of a collection.abstract void
Recieve notification that a document is being ended.abstract void
endElement
(XPathFragment xPathFragment, NamespaceResolver namespaceResolver) Receive notification that an element is being ended.void
endPrefixMapping
(String prefix) Receive notification that the scope of this namespace declaration has ended.void
endPrefixMappings
(NamespaceResolver namespaceResolver) void
flush()
void
INTERNALgetDOM()
INTERNAL: Returns the list of grouping elements currently stored on the MarshalRecordprotected String
getNameForFragment
(XPathFragment xPathFragment) protected byte[]
getPrefixBytes
(XPathFragment xPathFragment) protected String
getPrefixForFragment
(XPathFragment xPathFragment) protected String
getStringForQName
(QName qName) INTERNAL: The optional fragment used to wrap the text() mappingsgetValueToWrite
(QName schemaType, Object value, ConversionManager conversionManager) boolean
void
marshalWithoutRootElement
(ObjectBuilder treeObjectBuilder, Object object, Descriptor descriptor, Root root, boolean isXMLRoot) INTERNALvoid
namespaceDeclaration
(String prefix, String namespaceURI) Add the specified namespace declarationvoid
namespaceDeclarations
(NamespaceResolver namespaceResolver) INTERNAL: Add the namespace declarations to the XML document.void
nilComplex
(XPathFragment xPathFragment, NamespaceResolver namespaceResolver) Used when an nil attribute should be writtenvoid
nilSimple
(NamespaceResolver namespaceResolver) Used when an nil attribute should be writtenvoid
node
(Node node, NamespaceResolver resolver) Receive notification of a node.abstract void
node
(Node node, NamespaceResolver resolver, String qualifiedName, String rootUri) Receive notification of a node.void
openStartElement
(XPathFragment xPathFragment, NamespaceResolver namespaceResolver) Receive notification that an element is being started.openStartGroupingElements
(NamespaceResolver namespaceResolver) INTERNAL: Trigger that the grouping elements should be written.void
void
predicateAttribute
(XPathFragment xPathFragment, NamespaceResolver namespaceResolver) Marshal the attribute for the predicate if one was specified.protected String
processNamespaceResolverForXSIPrefix
(NamespaceResolver namespaceResolver) INTERNAL: Private function to process or create an entry in the NamespaceResolver for the xsi prefix.void
INTERNAL: Add the field-value pair to the document.void
removeGroupingElement
(XPathNode xPathNode) INTERNAL:void
setGroupingElement
(ArrayList<XPathNode> elements) INTERNAL: Sets the list of grouping elements to be marshalled on this record.void
setSession
(CoreAbstractSession session) void
This method is used to inform the MarshalRecord that the element events it is about to receive are part of a collection.abstract void
startDocument
(String encoding, String version) Receive notification that a document is being started.void
startPrefixMapping
(String prefix, String namespaceURI) Receive notification that a namespace has been declared.void
startPrefixMappings
(NamespaceResolver namespaceResolver) void
INTERNAL Writes the header, if appropriate.Methods inherited from class org.eclipse.persistence.internal.oxm.record.AbstractMarshalRecordImpl
addExtraNamespacesToNamespaceResolver, addXsiTypeAndClassIndicatorIfRequired, addXsiTypeAndClassIndicatorIfRequired, attributeWithoutQName, getConversionManager, getLeafElementType, getMarshaller, getNamespaceResolver, getNamespaceSeparator, getOwningObject, getSession, hasCustomNamespaceMapper, hasEqualNamespaceResolvers, isNamespaceAware, isXOPPackage, removeExtraNamespacesFromNamespaceResolver, resolveNamespacePrefix, setCustomNamespaceMapper, setEqualNamespaceResolvers, setLeafElementType, setLeafElementType, setMarshaller, setNamespaceResolver, setOwningObject, setXOPPackage, writeXsiTypeAttribute, writeXsiTypeAttribute
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.persistence.internal.oxm.record.AbstractMarshalRecord
addExtraNamespacesToNamespaceResolver, addXsiTypeAndClassIndicatorIfRequired, addXsiTypeAndClassIndicatorIfRequired, getLeafElementType, getMarshaller, getNamespaceResolver, getOwningObject, hasEqualNamespaceResolvers, isNamespaceAware, resolveNamespacePrefix, setCustomNamespaceMapper, setEqualNamespaceResolvers, setLeafElementType, setNamespaceResolver, setOwningObject, setXOPPackage, writeXsiTypeAttribute, writeXsiTypeAttribute
Methods inherited from interface org.eclipse.persistence.internal.oxm.record.MarshalRecord
attributeWithoutQName, hasCustomNamespaceMapper, isXOPPackage, removeExtraNamespacesFromNamespaceResolver, setLeafElementType, setMarshaller
Methods inherited from interface org.eclipse.persistence.internal.oxm.record.XMLRecord
getConversionManager, getNamespaceSeparator, getSession
-
Field Details
-
textWrapperFragment
-
COLON_W_SCHEMA_NIL_ATTRIBUTE
- See Also:
-
TRUE
- See Also:
-
-
Constructor Details
-
MarshalRecord
protected MarshalRecord()
-
-
Method Details
-
forceValueWrapper
public void forceValueWrapper()- Specified by:
forceValueWrapper
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver>
-
getPositionalNodes
-
getLocalName
-
getNamespaceURI
-
clear
public void clear() -
getDocument
-
getDOM
- Specified by:
getDOM
in interfaceAbstractMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Overrides:
getDOM
in classAbstractMarshalRecordImpl<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver>
-
addGroupingElement
INTERNAL: If an XPathNode does not have an associated NodeValue then add it to the MarshalRecord as a grouping element.- Specified by:
addGroupingElement
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver>
-
removeGroupingElement
INTERNAL:- Specified by:
removeGroupingElement
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver>
-
transformToXML
-
setSession
- Specified by:
setSession
in interfaceAbstractMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Overrides:
setSession
in classAbstractMarshalRecordImpl<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver>
-
add
INTERNAL: Add the field-value pair to the document.- Specified by:
add
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver>
-
put
INTERNAL: Add the field-value pair to the document.- Specified by:
put
in interfaceAbstractMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Overrides:
put
in classAbstractMarshalRecordImpl<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver>
-
namespaceDeclarations
INTERNAL: Add the namespace declarations to the XML document.- Parameters:
namespaceResolver
- The NamespaceResolver contains the namespace prefix and URI pairings that need to be declared.
-
emptyCollection
public boolean emptyCollection(XPathFragment xPathFragment, NamespaceResolver namespaceResolver, boolean openGrouping) Handle marshal of an empty collection.- Specified by:
emptyCollection
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Parameters:
openGrouping
- if grouping elements should be marshalled for empty collections
-
namespaceDeclaration
Add the specified namespace declaration- Specified by:
namespaceDeclaration
in interfaceAbstractMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Specified by:
namespaceDeclaration
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Overrides:
namespaceDeclaration
in classAbstractMarshalRecordImpl<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver>
-
defaultNamespaceDeclaration
Add the defaultNamespace declaration -
startDocument
Receive notification that a document is being started.- Parameters:
encoding
- The XML document will be encoded using this encoding.version
- This specifies the version of XML.
-
writeHeader
public void writeHeader()INTERNAL Writes the header, if appropriate. -
endDocument
public abstract void endDocument()Recieve notification that a document is being ended. -
marshalWithoutRootElement
public void marshalWithoutRootElement(ObjectBuilder treeObjectBuilder, Object object, Descriptor descriptor, Root root, boolean isXMLRoot) INTERNAL -
startPrefixMapping
Receive notification that a namespace has been declared.- Specified by:
startPrefixMapping
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Parameters:
prefix
- The namespace prefix.namespaceURI
- The namespace URI.
-
startPrefixMappings
-
endPrefixMapping
Receive notification that the scope of this namespace declaration has ended.- Specified by:
endPrefixMapping
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Parameters:
prefix
- The namespace prefix.
-
endPrefixMappings
-
openStartElement
Receive notification that an element is being started.- Specified by:
openStartElement
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Parameters:
xPathFragment
- The XPathFragment contains the name and prefix information about the XML element being ended.namespaceResolver
- The NamespaceResolver can be used to resolve the namespace URI for the namespace prefix held by the XPathFragment (if required).
-
element
Receive notification of an element.- Parameters:
frag
- The XPathFragment of the element
-
attribute
public abstract void attribute(XPathFragment xPathFragment, NamespaceResolver namespaceResolver, String value) Receive notification of an attribute.- Specified by:
attribute
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Parameters:
xPathFragment
- The XPathFragment contains the name and prefix information about the XML element being ended.namespaceResolver
- The NamespaceResolver can be used to resolve the namespace URI for the namespace prefix held by the XPathFragment (if required).value
- This is the complete value for the attribute.
-
attribute
Receive notification of an attribute.- Specified by:
attribute
in interfaceAbstractMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Specified by:
attribute
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Overrides:
attribute
in classAbstractMarshalRecordImpl<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Parameters:
namespaceURI
- The namespace URI, if the attribute is not namespace qualified the value of this parameter wil be null.localName
- The local name of the attribute.qName
- The qualified name of the attribute.value
- This is the complete value for the attribute.
-
closeStartElement
public abstract void closeStartElement()Receive notification that all of the attribute events have occurred for the most recent element that has been started.- Specified by:
closeStartElement
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver>
-
endElement
Receive notification that an element is being ended.- Specified by:
endElement
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Parameters:
xPathFragment
- The XPathFragment contains the name and prefix information about the XML element being ended.namespaceResolver
- The NamespaceResolver can be used to resolve the namespace URI for the namespace prefix held by the XPathFragment (if required).
-
characters
Receive notification of character data.- Specified by:
characters
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Parameters:
value
- This is the entire value of the text node.
-
attribute
public void attribute(XPathFragment xPathFragment, NamespaceResolver namespaceResolver, Object value, QName schemaType) Convert the value if necessary and write out the attribute and converted value.- Specified by:
attribute
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Since:
- EclipseLink 2.4
-
characters
Convert the value if necessary and write out the converted value.- Specified by:
characters
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Since:
- EclipseLink 2.4
-
getValueToWrite
- Specified by:
getValueToWrite
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver>
-
getStringForQName
-
cdata
Receive notification of character data to be wrapped in a CDATA node.- Specified by:
cdata
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Parameters:
value
- This is the value of the text to be wrapped
-
node
Receive notification of a node.- Specified by:
node
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Parameters:
node
- The Node to be added to the documentresolver
- The NamespaceResolver can be used to resolve the namespace URI/prefix of the node
-
node
public abstract void node(Node node, NamespaceResolver resolver, String qualifiedName, String rootUri) Receive notification of a node.- Parameters:
node
- The Node to be added to the documentresolver
- The NamespaceResolver can be used to resolve thequalifiedName
- replacement root name for the noderootUri
- replacement root namespace for the node namespace URI/prefix of the node
-
openStartGroupingElements
INTERNAL: Trigger that the grouping elements should be written. This is normally done when something like a mapping has a non-null value that is marshalled.- Specified by:
openStartGroupingElements
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Parameters:
namespaceResolver
- The NamespaceResolver can be used to resolve the namespace URI for the namespace prefix held by the XPathFragment (if required).
-
closeStartGroupingElements
- Specified by:
closeStartGroupingElements
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver>
-
addPositionalNodes
-
beforeContainmentMarshal
- Specified by:
beforeContainmentMarshal
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver>
-
afterContainmentMarshal
- Specified by:
afterContainmentMarshal
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver>
-
getGroupingElements
INTERNAL: Returns the list of grouping elements currently stored on the MarshalRecord- Specified by:
getGroupingElements
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver>
-
setGroupingElement
INTERNAL: Sets the list of grouping elements to be marshalled on this record.- Specified by:
setGroupingElement
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver>
-
predicateAttribute
Marshal the attribute for the predicate if one was specified.- Specified by:
predicateAttribute
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver>
-
startCollection
public void startCollection()This method is used to inform the MarshalRecord that the element events it is about to receive are part of a collection.- Specified by:
startCollection
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Since:
- EclipseLink 2.4
- See Also:
-
emptyAttribute
Used when an nil attribute should be written- Specified by:
emptyAttribute
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Since:
- EclipseLink 2.4
-
emptyComplex
Used when an nil attribute should be written- Specified by:
emptyComplex
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Since:
- EclipseLink 2.4
-
emptySimple
Used when an nil attribute should be written- Specified by:
emptySimple
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Since:
- EclipseLink 2.4
-
nilSimple
Used when an nil attribute should be written- Specified by:
nilSimple
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Since:
- EclipseLink 2.4
-
nilComplex
Used when an nil attribute should be written- Specified by:
nilComplex
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Since:
- EclipseLink 2.4
-
endCollection
public void endCollection()This method is used to inform the MarshalRecord that it is done receiving element events that are part of a collection.- Specified by:
endCollection
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Since:
- EclipseLink 2.4
- See Also:
-
processNamespaceResolverForXSIPrefix
INTERNAL: Private function to process or create an entry in the NamespaceResolver for the xsi prefix.- Returns:
- xsi prefix
- Since:
- EclipseLink 2.4
-
getTextWrapperFragment
INTERNAL: The optional fragment used to wrap the text() mappings- Specified by:
getTextWrapperFragment
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver> - Since:
- 2.4
-
getNameForFragment
-
getPrefixBytes
-
getPrefixForFragment
-
getCycleDetectionStack
INTERNAL- Specified by:
getCycleDetectionStack
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver>
-
isWrapperAsCollectionName
public boolean isWrapperAsCollectionName()- Specified by:
isWrapperAsCollectionName
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver>
-
getCurrentAttributeGroup
- Specified by:
getCurrentAttributeGroup
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver>
-
pushAttributeGroup
- Specified by:
pushAttributeGroup
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver>
-
popAttributeGroup
public void popAttributeGroup()- Specified by:
popAttributeGroup
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver>
-
flush
public void flush()- Specified by:
flush
in interfaceMarshalRecord<CoreAbstractSession,
CoreField, MARSHALLER extends Marshaller, NamespaceResolver>
-