Class XMLCollectionReferenceMappingNodeValue
- java.lang.Object
-
- org.eclipse.persistence.internal.oxm.NodeValue
-
- org.eclipse.persistence.internal.oxm.MappingNodeValue
-
- org.eclipse.persistence.internal.oxm.XMLCollectionReferenceMappingNodeValue
-
- All Implemented Interfaces:
ContainerValue
public class XMLCollectionReferenceMappingNodeValue extends MappingNodeValue implements ContainerValue
INTERNAL:Purpose: Class to handle (un)marshal operations for XMLCollectionReferenceMappings.
An instance of this class is required for each XMLField set on the mapping, that is, for each source field in the source-target key field association list.
When unmarshalling, an instance of org.eclipse.persistence.internal.oxm.Reference is created on a per mapping basis (keyed on source object instance) and sorted on the associated session's org.eclipse.persistence.internal.oxm.ReferenceResolver instance. Each target primary key value is stored in the Reference instance for use during mapping resolution phase after unmarshalling completes.
When marshalling, the target object's primary key value that is mapped to this NodeValue's XMLField (in the XMLObjectReferenceMapping's source-target key field association list) is retrieved and written out.
- See Also:
Reference
,ReferenceResolver
,XMLObjectReferenceMapping
-
-
Constructor Summary
Constructors Constructor Description XMLCollectionReferenceMappingNodeValue(CollectionReferenceMapping xmlCollectionReferenceMapping, Field xmlField)
This constructor sets the XMLCollectionReferenceMapping and XMLField members to the provided values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
attribute(UnmarshalRecord unmarshalRecord, String namespaceURI, String localName, String value)
Handle attribute operation.void
endElement(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord)
Handle endElement operation.void
endElement(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord, Object container)
Object
getContainerInstance()
CoreContainerPolicy
getContainerPolicy()
int
getIndex()
INTERNAL: Set to track the index of the corresponding containerInstance in the containerInstances Object[] on UnmarshalRecord Set during TreeObjectBuilder initializationCollectionReferenceMapping
getMapping()
Return the mapping associated with this node value.boolean
getReuseContainer()
Return true if the original container on the object should be used if present.boolean
isContainerValue()
INTERNAL:boolean
isDefaultEmptyContainer()
INTERNAL Return true if an empty container should be set on the object if there is no presence of the collection in the XML document.boolean
isMarshalNodeValue()
boolean
isOwningNode(XPathFragment xPathFragment)
Indicate if the next XPathFragment is an attribute or text() node.boolean
isWrapperAllowedAsCollectionName()
For media types that provide a native representation of collections (such as JSON arrays), can the representation be simplified so that the grouping element can be used as the collection name.boolean
marshal(XPathFragment xPathFragment, MarshalRecord marshalRecord, Object object, CoreAbstractSession session, NamespaceResolver namespaceResolver)
Handle the marshal operation for this NodeValue.boolean
marshalSingleValue(XPathFragment xPathFragment, MarshalRecord marshalRecord, Object object, Object value, CoreAbstractSession session, NamespaceResolver namespaceResolver, MarshalContext marshalContext)
INTERNAL: This method provides an optimization in cases where the value has already been calculated.void
setContainerInstance(Object object, Object containerInstance)
void
setIndex(int index)
INTERNAL: Used to track the index of the corresponding containerInstance in the containerInstances Object[] on UnmarshalRecordboolean
startElement(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord, Attributes atts)
INTERNAL:-
Methods inherited from class org.eclipse.persistence.internal.oxm.MappingNodeValue
addTypeAttribute, isMappingNodeValue, updateNamespaces
-
Methods inherited from class org.eclipse.persistence.internal.oxm.NodeValue
buildSelfRecord, endSelfNodeValue, getXPathNode, isAnyMappingNodeValue, isMarshalOnlyNodeValue, isMixedContentNodeValue, isNullCapableValue, isUnmarshalNodeValue, isWhitespaceAware, isWrapperNodeValue, marshal, marshal, marshal, marshalSelfAttributes, marshalSingleValue, setXPathNode
-
-
-
-
Constructor Detail
-
XMLCollectionReferenceMappingNodeValue
public XMLCollectionReferenceMappingNodeValue(CollectionReferenceMapping xmlCollectionReferenceMapping, Field xmlField)
This constructor sets the XMLCollectionReferenceMapping and XMLField members to the provided values.- Parameters:
xmlCollectionReferenceMapping
-
-
-
Method Detail
-
attribute
public void attribute(UnmarshalRecord unmarshalRecord, String namespaceURI, String localName, String value)
Handle attribute operation. Here we will create and populate an org.eclipse.persistence.internal.oxm.Reference instance to be used during the mapping resolution stage. In particular, the primary key value for this element will be added to the Reference object's map of target primary key values - based on the target key field name. Note that if a reference already exists for the xmlCollectionReferenceMapping's source object instance, we will simply add to the target pk value list. The Reference object is stored on the ReferenceResolver associated with the UnmarshalRecord's session.
-
endElement
public void endElement(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord)
Handle endElement operation. Here we will create and populate an org.eclipse.persistence.internal.oxm.Reference instance to be used during the mapping resolution stage. In particular, the primary key value for this element will be added to the Reference object's map of target primary key values - based on the target key field name. Note that if a reference already exists for the xmlCollectionReferenceMapping's source object instance, we will simply add to the target pk value list. The Reference object is stored on the ReferenceResolver associated with the UnmarshalRecord's session.- Overrides:
endElement
in classNodeValue
-
endElement
public void endElement(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord, Object container)
- Overrides:
endElement
in classNodeValue
-
isOwningNode
public boolean isOwningNode(XPathFragment xPathFragment)
Indicate if the next XPathFragment is an attribute or text() node.- Overrides:
isOwningNode
in classNodeValue
- Returns:
-
isWrapperAllowedAsCollectionName
public boolean isWrapperAllowedAsCollectionName()
Description copied from interface:ContainerValue
For media types that provide a native representation of collections (such as JSON arrays), can the representation be simplified so that the grouping element can be used as the collection name.- Specified by:
isWrapperAllowedAsCollectionName
in interfaceContainerValue
-
isContainerValue
public boolean isContainerValue()
Description copied from class:NodeValue
INTERNAL:- Overrides:
isContainerValue
in classNodeValue
- Returns:
- Returns true if the NodeValue implements ContainerValue.
- See Also:
ContainerValue
-
getContainerInstance
public Object getContainerInstance()
- Specified by:
getContainerInstance
in interfaceContainerValue
-
setContainerInstance
public void setContainerInstance(Object object, Object containerInstance)
- Specified by:
setContainerInstance
in interfaceContainerValue
-
getContainerPolicy
public CoreContainerPolicy getContainerPolicy()
- Specified by:
getContainerPolicy
in interfaceContainerValue
-
marshal
public boolean marshal(XPathFragment xPathFragment, MarshalRecord marshalRecord, Object object, CoreAbstractSession session, NamespaceResolver namespaceResolver)
Handle the marshal operation for this NodeValue. Each of the target object's primary key values that are mapped to the collection mapping's fields (in the XMLCollectionReferenceMapping's source-target key field association list) are retrieved and written out.
-
startElement
public boolean startElement(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord, Attributes atts)
Description copied from class:NodeValue
INTERNAL:- Overrides:
startElement
in classNodeValue
- Parameters:
xPathFragment
-unmarshalRecord
-atts
-- Returns:
-
marshalSingleValue
public boolean marshalSingleValue(XPathFragment xPathFragment, MarshalRecord marshalRecord, Object object, Object value, CoreAbstractSession session, NamespaceResolver namespaceResolver, MarshalContext marshalContext)
Description copied from class:NodeValue
INTERNAL: This method provides an optimization in cases where the value has already been calculated.- Specified by:
marshalSingleValue
in interfaceContainerValue
- Specified by:
marshalSingleValue
in classNodeValue
-
getMapping
public CollectionReferenceMapping getMapping()
Description copied from class:MappingNodeValue
Return the mapping associated with this node value.- Specified by:
getMapping
in interfaceContainerValue
- Specified by:
getMapping
in classMappingNodeValue
-
getReuseContainer
public boolean getReuseContainer()
Description copied from interface:ContainerValue
Return true if the original container on the object should be used if present. If it is not present then the container policy will be used to create the container.- Specified by:
getReuseContainer
in interfaceContainerValue
-
isMarshalNodeValue
public boolean isMarshalNodeValue()
- Overrides:
isMarshalNodeValue
in classNodeValue
-
setIndex
public void setIndex(int index)
INTERNAL: Used to track the index of the corresponding containerInstance in the containerInstances Object[] on UnmarshalRecord- Specified by:
setIndex
in interfaceContainerValue
-
getIndex
public int getIndex()
INTERNAL: Set to track the index of the corresponding containerInstance in the containerInstances Object[] on UnmarshalRecord Set during TreeObjectBuilder initialization- Specified by:
getIndex
in interfaceContainerValue
-
isDefaultEmptyContainer
public boolean isDefaultEmptyContainer()
INTERNAL Return true if an empty container should be set on the object if there is no presence of the collection in the XML document.- Specified by:
isDefaultEmptyContainer
in interfaceContainerValue
- Since:
- EclipseLink 2.3.3
-
-