Class XMLFragmentMapping

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, org.eclipse.persistence.internal.oxm.mappings.DirectMapping<org.eclipse.persistence.internal.sessions.AbstractSession,​AttributeAccessor,​org.eclipse.persistence.internal.queries.ContainerPolicy,​Converter,​ClassDescriptor,​org.eclipse.persistence.internal.helper.DatabaseField,​XMLMarshaller,​Session,​XMLUnmarshaller,​XMLRecord>, org.eclipse.persistence.internal.oxm.mappings.FragmentMapping<org.eclipse.persistence.internal.sessions.AbstractSession,​AttributeAccessor,​org.eclipse.persistence.internal.queries.ContainerPolicy,​ClassDescriptor,​org.eclipse.persistence.internal.helper.DatabaseField,​Session,​XMLRecord>, org.eclipse.persistence.internal.oxm.mappings.Mapping<org.eclipse.persistence.internal.sessions.AbstractSession,​AttributeAccessor,​org.eclipse.persistence.internal.queries.ContainerPolicy,​ClassDescriptor,​org.eclipse.persistence.internal.helper.DatabaseField,​XMLRecord>, org.eclipse.persistence.internal.oxm.mappings.XMLConverterMapping<XMLMarshaller,​Session,​XMLUnmarshaller>, MapComponentMapping, MapKeyMapping, XMLMapping, XMLNillableMapping

    public class XMLFragmentMapping
    extends XMLDirectMapping
    implements org.eclipse.persistence.internal.oxm.mappings.FragmentMapping<org.eclipse.persistence.internal.sessions.AbstractSession,​AttributeAccessor,​org.eclipse.persistence.internal.queries.ContainerPolicy,​ClassDescriptor,​org.eclipse.persistence.internal.helper.DatabaseField,​Session,​XMLRecord>

    Purpose: This mapping provides a means to keep a part of the xml tree as a DOM element.

    Setting the XPath: TopLink XML mappings make use of XPath statements to find the relevant data in an XML document. The XPath statement is relative to the context node specified in the descriptor. The XPath may contain path and positional information; the last node in the XPath forms the local root node for the fragment. The XPath is specified on the mapping using the setXPath method.

    XPath Description
    phone-number The phone-number information is stored in the phone-number element.
    contact-info/phone-number The XPath statement may be used to specify any valid path.

    Sample Configuration:

    
     XMLFragmentCollectionMapping mapping = new XMLFragmentCollectionMapping();
     mapping.setAttributeName("phoneNumber");
     mapping.setXPath("contact-info/phone-number");
     
     
    See Also:
    Serialized Form
    • Constructor Detail

      • XMLFragmentMapping

        public XMLFragmentMapping()
    • Method Detail

      • writeFromObjectIntoRow

        public void writeFromObjectIntoRow​(java.lang.Object object,
                                           org.eclipse.persistence.internal.sessions.AbstractRecord row,
                                           org.eclipse.persistence.internal.sessions.AbstractSession session,
                                           DatabaseMapping.WriteType writeType)
        INTERNAL: Get a value from the object and set that in the respective field of the row.
        Overrides:
        writeFromObjectIntoRow in class XMLDirectMapping
      • valueFromRow

        public java.lang.Object valueFromRow​(org.eclipse.persistence.internal.sessions.AbstractRecord row,
                                             org.eclipse.persistence.internal.queries.JoinedAttributeManager joinManager,
                                             ObjectBuildingQuery query,
                                             org.eclipse.persistence.internal.identitymaps.CacheKey cacheKey,
                                             org.eclipse.persistence.internal.sessions.AbstractSession executionSession,
                                             boolean isTargetProtected,
                                             java.lang.Boolean[] wasCacheUsed)
        Description copied from class: XMLDirectMapping
        INTERNAL: Return the mapping's attribute value from the row. The execution session is passed for the case of building a UnitOfWork clone directly from a row, the session set in the query will not know which platform to use for converting the value. Allows the correct session to be passed in.
        Overrides:
        valueFromRow in class XMLDirectMapping
      • writeSingleValue

        public void writeSingleValue​(java.lang.Object attributeValue,
                                     java.lang.Object parent,
                                     XMLRecord row,
                                     org.eclipse.persistence.internal.sessions.AbstractSession session)
        Description copied from interface: XMLMapping
        INTERNAL: A method that marshals a single value to the provided Record based on this mapping's XPath. Used for Sequenced marshalling.
        Specified by:
        writeSingleValue in interface org.eclipse.persistence.internal.oxm.mappings.Mapping<org.eclipse.persistence.internal.sessions.AbstractSession,​AttributeAccessor,​org.eclipse.persistence.internal.queries.ContainerPolicy,​ClassDescriptor,​org.eclipse.persistence.internal.helper.DatabaseField,​XMLRecord>
        Specified by:
        writeSingleValue in interface XMLMapping
        Overrides:
        writeSingleValue in class XMLDirectMapping
        Parameters:
        attributeValue - - The value to be marshalled
        row - - The Record the value is being marshalled too.
      • setXPath

        public void setXPath​(java.lang.String xpathString)
        Description copied from class: XMLDirectMapping
        Set the Mapping field name attribute to the given XPath String
        Specified by:
        setXPath in interface org.eclipse.persistence.internal.oxm.mappings.DirectMapping<org.eclipse.persistence.internal.sessions.AbstractSession,​AttributeAccessor,​org.eclipse.persistence.internal.queries.ContainerPolicy,​Converter,​ClassDescriptor,​org.eclipse.persistence.internal.helper.DatabaseField,​XMLMarshaller,​Session,​XMLUnmarshaller,​XMLRecord>
        Overrides:
        setXPath in class XMLDirectMapping
        Parameters:
        xpathString - String
      • isAbstractDirectMapping

        public boolean isAbstractDirectMapping()
        Description copied from class: AbstractDirectMapping
        INTERNAL:
        Specified by:
        isAbstractDirectMapping in interface org.eclipse.persistence.internal.oxm.mappings.Mapping<org.eclipse.persistence.internal.sessions.AbstractSession,​AttributeAccessor,​org.eclipse.persistence.internal.queries.ContainerPolicy,​ClassDescriptor,​org.eclipse.persistence.internal.helper.DatabaseField,​XMLRecord>
        Overrides:
        isAbstractDirectMapping in class AbstractDirectMapping