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

B32476-04

oracle.toplink.ox.mappings
Class XMLAnyCollectionMapping

java.lang.Object
  extended by oracle.toplink.mappings.DatabaseMapping
      extended by oracle.toplink.ox.mappings.XMLAnyCollectionMapping
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, ContainerMapping, oracle.toplink.ox.mappings.XMLMapping

public class XMLAnyCollectionMapping
extends DatabaseMapping
implements oracle.toplink.ox.mappings.XMLMapping, ContainerMapping

Any collection XML mappings map an attribute that contains a heterogenous collection of objects to multiple XML elements. Unlike composite collection XML mappings, the referenced objects may be of different types (including String), and do not need to be related to each other through inheritance or a common interface. The corresponding object attribute should be generic enough for all possible application values. Note that each of the referenced objects (except String) must specify a default root element on their descriptor.

Any collection mappings are useful with the following XML schema constructs:

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 node type, path, and positional information. The XPath is specified on the mapping using the setXPath method. Note that for XML Any Collection Mappings the XPath is optional.

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

XPath Description
contact-methods The name information is stored in the contact-methods element.
contact-methods/info The XPath statement may be used to specify any valid path.
contact-methods[2] The XPath statement may contain positional information. In this case the contact information is stored in the second occurrence of the contact-methods element.

Mapping an element of type xs:anyType as an Any Collection Mapping:

XML Schema
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element name="customer" type="customer-type"/>
  <xsd:complexType name="customer-type">
    <xsd:sequence>
      <xsd:element name="contact-methods" type="xsd:anyType"/>
    </xsd:sequence>
  </xsd:complexType>
  <xsd:element name="address">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="street" type="xsd:string"/>
        <xsd:element name="city" type="xsd:string"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="phone-number" type="xsd:string"/>
</xsd:schema>

Code Sample
XMLAnyCollectionMapping contactMethodsMapping = new XMLAnyCollectionMapping();
contactMethodsMapping.setAttributeName("contactMethods");
contactMethodsMapping.setXPath("contact-methods");

More Information: For more information about using the XML Any 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
XMLAnyCollectionMapping()
           
 
Method Summary
 UnmarshalKeepAsElementPolicy getKeepAsElementPolicy()
           
 boolean isMixedContent()
           
 void setContainerPolicy(oracle.toplink.internal.queryframework.ContainerPolicy cp)
          Set the mapping's container policy.
 void setField(DatabaseField field)
           
 void setKeepAsElementPolicy(UnmarshalKeepAsElementPolicy policy)
           
 void setMixedContent(boolean mixed)
           
 void setUseXMLRoot(boolean useXMLRoot)
           
 void setXPath(java.lang.String xpath)
           
 void useCollectionClass(java.lang.Class concreteContainerClass)
          Configure the mapping to use an instance of the specified container class to hold the target objects.
 void useMapClass(java.lang.Class concreteContainerClass, java.lang.String methodName)
          Configure the mapping to use an instance of the specified container class to hold the target objects.
 boolean usesXMLRoot()
           
 
Methods inherited from class oracle.toplink.mappings.DatabaseMapping
getAttributeAccessor, getAttributeClassification, getAttributeName, getGetMethodName, getProperty, getReferenceDescriptor, 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

XMLAnyCollectionMapping

public XMLAnyCollectionMapping()
Method Detail

setXPath

public void setXPath(java.lang.String xpath)

setContainerPolicy

public void setContainerPolicy(oracle.toplink.internal.queryframework.ContainerPolicy cp)
Description copied from interface: oracle.toplink.mappings.ContainerMapping
Set the mapping's container policy.

Specified by:
setContainerPolicy in interface ContainerMapping

setField

public void setField(DatabaseField field)

useCollectionClass

public void useCollectionClass(java.lang.Class concreteContainerClass)
Configure the mapping to use an instance of the specified container class to hold the target objects.

jdk1.2.x: The container class must implement (directly or indirectly) the Collection interface.

jdk1.1.x: The container class must be a subclass of Vector.

Specified by:
useCollectionClass in interface ContainerMapping

useMapClass

public void useMapClass(java.lang.Class concreteContainerClass,
                        java.lang.String methodName)
Description copied from interface: oracle.toplink.mappings.ContainerMapping
Configure the mapping to use an instance of the specified container class to hold the target objects. The key used to index a value in the Map is the value returned by a call to the specified zero-argument method. The method must be implemented by the class (or a superclass) of any value to be inserted into the Map.

The container class must implement (directly or indirectly) the java.util.Map interface.

To facilitate resolving the method, the mapping's referenceClass must set before calling this method.

Specified by:
useMapClass in interface ContainerMapping

setUseXMLRoot

public void setUseXMLRoot(boolean useXMLRoot)

usesXMLRoot

public boolean usesXMLRoot()

isMixedContent

public boolean isMixedContent()

setMixedContent

public void setMixedContent(boolean mixed)

getKeepAsElementPolicy

public UnmarshalKeepAsElementPolicy getKeepAsElementPolicy()

setKeepAsElementPolicy

public void setKeepAsElementPolicy(UnmarshalKeepAsElementPolicy policy)

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