Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle TopLink
11g Release 1 (11.1.1)

B32476-02


oracle.toplink.ox.mappings
Class XMLCompositeObjectMapping

java.lang.Object
  extended by oracle.toplink.mappings.DatabaseMapping
      extended by oracle.toplink.mappings.AggregateMapping
          extended by oracle.toplink.mappings.foundation.AbstractCompositeObjectMapping
              extended by oracle.toplink.ox.mappings.XMLCompositeObjectMapping

All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, oracle.toplink.ox.mappings.XMLMapping, oracle.toplink.ox.mappings.XMLNillableMapping

public class XMLCompositeObjectMapping
extends AbstractCompositeObjectMapping
implements oracle.toplink.ox.mappings.XMLMapping, oracle.toplink.ox.mappings.XMLNillableMapping

Composite object XML mappings represent a relationship between two classes. In XML, the "owned" class may be nested with the element tag representing the "owning" class. This mapping is, by definition, privately owned.

Composite object XML mappings can be used in the following scenarios:

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 composite object. The XPath is specified on the mapping using the setXPath method.

The following XPath statements may be used to specify the location of XML data relating to an object's name attribute:

XPath Description
. Indicates "self".
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.
phone-number[2] The XPath statement may contain positional information. In this case the phone-number information is stored in the second occurrence of the phone-number element.

Mapping into the Parent Record: The composite object may be mapped into the parent record in a corresponding XML document.

XML Schema
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element />
  <xsd:complexType >
    <xsd:sequence>
      <xsd:element />
      <xsd:element />
      <xsd:element />
      <xsd:element />
    </xsd:sequence>
  </xsd:complexType>
</xsd:schema>

Code Sample
XMLCompositeObjectMapping addressMapping = new XMLCompositeObjectMapping();
addressMapping.setAttributeName("address");
addressMapping.setXPath(".");
addressMapping.setReferenceClass(Address.class);

Mapping to an Element: The composite object may be mapped to an element in a corresponding XML document.

XML Schema
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element />
  <xsd:complexType >
    <xsd:sequence>
      <xsd:element />
      <xsd:element />
      <xsd:element >
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element />
            <xsd:element />
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>
</xsd:schema>

Code Sample
XMLCompositeObjectMapping addressMapping = new XMLCompositeObjectMapping();
addressMapping.setAttributeName("address");
addressMapping.setXPath("address");
addressMapping.setReferenceClass(Address.class);

More Information: For more information about using the XML Composite Object Mapping, see the "Understanding XML Mappings" chapter of the Oracle TopLink Developer's Guide.

Since:
Oracle TopLink 10g Release 2 (10.1.3)
See Also:
Serialized Form

Constructor Summary
XMLCompositeObjectMapping()
           

 

Method Summary
 void configureNestedRow(oracle.toplink.internal.sessions.AbstractRecord parent, oracle.toplink.internal.sessions.AbstractRecord child)
           
 ClassDescriptor getReferenceDescriptor(DOMRecord xmlRecord)
           
 java.lang.String getXPath()
          Get the XPath String
 void setNullPolicy(AbstractNullPolicy aNullPolicy)
          Set the AbstractNullPolicy on the mapping
The default policy is NullPolicy.
 void setXPath(java.lang.String xpathString)
          Set the Mapping field name attribute to the given XPath String
 java.lang.Object valueFromRow(java.lang.Object fieldValue, XMLRecord nestedRow, oracle.toplink.internal.queryframework.JoinedAttributeManager joinManager, ObjectBuildingQuery sourceQuery, oracle.toplink.internal.sessions.AbstractSession executionSession)
           

 

Methods inherited from class oracle.toplink.mappings.foundation.AbstractCompositeObjectMapping
getConverter, hasConverter, setConverter, setField

 

Methods inherited from class oracle.toplink.mappings.AggregateMapping
getReferenceClass, setReferenceClass

 

Methods inherited from class oracle.toplink.mappings.DatabaseMapping
getAttributeAccessor, getAttributeClassification, getAttributeName, getGetMethodName, getProperty, getSetMethodName, isLazy, isOptional, isUsingMethodAccess, readOnly, readWrite, setAttributeAccessor, setAttributeName, setGetMethodName, setIsLazy, setIsOptional, setIsReadOnly, setProperty, setSetMethodName, setWeight, simpleAddToCollectionChangeRecord, simpleRemoveFromCollectionChangeRecord

 

Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

 

Constructor Detail

XMLCompositeObjectMapping

public XMLCompositeObjectMapping()

Method Detail

setNullPolicy

public void setNullPolicy(AbstractNullPolicy aNullPolicy)
Set the AbstractNullPolicy on the mapping
The default policy is NullPolicy.
Specified by:
setNullPolicy in interface oracle.toplink.ox.mappings.XMLNillableMapping
Parameters:
aNullPolicy -

getXPath

public java.lang.String getXPath()
Get the XPath String
Returns:
String the XPath String associated with this Mapping

setXPath

public void setXPath(java.lang.String xpathString)
Set the Mapping field name attribute to the given XPath String
Parameters:
xpathString - String

valueFromRow

public java.lang.Object valueFromRow(java.lang.Object fieldValue,
                                     XMLRecord nestedRow,
                                     oracle.toplink.internal.queryframework.JoinedAttributeManager joinManager,
                                     ObjectBuildingQuery sourceQuery,
                                     oracle.toplink.internal.sessions.AbstractSession executionSession)
                              throws DatabaseException
Throws:
DatabaseException

configureNestedRow

public void configureNestedRow(oracle.toplink.internal.sessions.AbstractRecord parent,
                               oracle.toplink.internal.sessions.AbstractRecord child)

getReferenceDescriptor

public ClassDescriptor getReferenceDescriptor(DOMRecord xmlRecord)

Skip navigation links

Copyright © 1998, 2009, Oracle. All Rights Reserved.