Class 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 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.
        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
      • isOwningNode

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