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 XMLCompositeCollectionMapping

java.lang.Object
  extended by oracle.toplink.mappings.DatabaseMapping
      extended by oracle.toplink.mappings.AggregateMapping
          extended by oracle.toplink.mappings.foundation.AbstractCompositeCollectionMapping
              extended by oracle.toplink.ox.mappings.XMLCompositeCollectionMapping

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

public class XMLCompositeCollectionMapping
extends AbstractCompositeCollectionMapping
implements oracle.toplink.ox.mappings.XMLMapping

Composite collection XML mappings map an attribute that contains a homogeneous collection of objects to multiple XML elements. Use composite collection XML mappings to represent one-to-many relationships. Composite collection XML mappings can reference any class that has a TopLink descriptor. The attribute in the object mapped must implement either the Java Collection interface (for example, Vector or HashSet) or Map interface (for example, Hashtable or TreeMap). The CompositeCollectionMapping class allows a reference to the mapped class and the indexing type for that class. This mapping is, by definition, privately owned.

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
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 a Composite Collection:

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:sequence>
          <xsd:attribute />
        </xsd:complexType>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>
</xsd:schema>

Code Sample
XMLCompositeCollectionMapping phoneNumbersMapping = new XMLCompositeCollectionMapping();
phoneNumbersMapping.setAttributeName("phoneNumbers");
phoneNumbersMapping.setXPath("phone-number");
phoneNumbersMapping.setReferenceClass(PhoneNumber.class);

More Information: For more information about using the XML Composite Collection 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
XMLCompositeCollectionMapping()
           

 

Method Summary
 ClassDescriptor getReferenceDescriptor(DOMRecord xmlRecord)
           
 java.lang.String getXPath()
          Get the XPath String
 void setXPath(java.lang.String xpathString)
          Set the Mapping field name attribute to the given XPath String

 

Methods inherited from class oracle.toplink.mappings.foundation.AbstractCompositeCollectionMapping
getConverter, hasConverter, setContainerPolicy, setConverter, setField, simpleAddToCollectionChangeRecord, simpleRemoveFromCollectionChangeRecord, useCollectionClass, useCollectionClassName, useListClassName, useMapClass, useMapClassName

 

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

 

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

 

Constructor Detail

XMLCompositeCollectionMapping

public XMLCompositeCollectionMapping()

Method Detail

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

getReferenceDescriptor

public ClassDescriptor getReferenceDescriptor(DOMRecord xmlRecord)

Skip navigation links

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