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:
  • Constructor Details

    • XMLCollectionReferenceMappingNodeValue

      public XMLCollectionReferenceMappingNodeValue(CollectionReferenceMapping xmlCollectionReferenceMapping, Field xmlField)
      This constructor sets the XMLCollectionReferenceMapping and XMLField members to the provided values.
  • Method Details

    • 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.
      Overrides:
      attribute in class NodeValue
    • 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 class NodeValue
    • endElement

      public void endElement(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord, Object container)
      Overrides:
      endElement in class NodeValue
    • isOwningNode

      public boolean isOwningNode(XPathFragment xPathFragment)
      Indicate if the next XPathFragment is an attribute or text() node.
      Overrides:
      isOwningNode in class NodeValue
    • 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 interface ContainerValue
    • isContainerValue

      public boolean isContainerValue()
      Description copied from class: NodeValue
      INTERNAL:
      Overrides:
      isContainerValue in class NodeValue
      Returns:
      Returns true if the NodeValue implements ContainerValue.
      See Also:
    • getContainerInstance

      public Object getContainerInstance()
      Specified by:
      getContainerInstance in interface ContainerValue
    • setContainerInstance

      public void setContainerInstance(Object object, Object containerInstance)
      Specified by:
      setContainerInstance in interface ContainerValue
    • getContainerPolicy

      public CoreContainerPolicy getContainerPolicy()
      Specified by:
      getContainerPolicy in interface ContainerValue
    • 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.
      Specified by:
      marshal in class NodeValue
    • startElement

      public boolean startElement(XPathFragment xPathFragment, UnmarshalRecord unmarshalRecord, Attributes atts)
      Description copied from class: NodeValue
      INTERNAL:
      Overrides:
      startElement in class NodeValue
    • 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 interface ContainerValue
      Specified by:
      marshalSingleValue in class NodeValue
    • getMapping

      public CollectionReferenceMapping getMapping()
      Description copied from class: MappingNodeValue
      Return the mapping associated with this node value.
      Specified by:
      getMapping in interface ContainerValue
      Specified by:
      getMapping in class MappingNodeValue
    • 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 interface ContainerValue
    • isMarshalNodeValue

      public boolean isMarshalNodeValue()
      Overrides:
      isMarshalNodeValue in class NodeValue
    • 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 interface ContainerValue
    • 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 interface ContainerValue
    • 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 interface ContainerValue
      Since:
      EclipseLink 2.3.3