Top Description Fields Constructors Methods
org.eclipse.persistence.oxm.mappings

public Class XMLAnyCollectionMapping

extends XMLAbstractAnyMapping
implements AnyCollectionMapping<AbstractSession, AttributeAccessor, ContainerPolicy, XMLConverter, ClassDescriptor, DatabaseField, XMLMarshaller, Session, UnmarshalKeepAsElementPolicy, XMLUnmarshaller, XMLRecord>, XMLMapping, ContainerMapping
Class Inheritance
All Implemented Interfaces
org.eclipse.persistence.mappings.ContainerMapping, org.eclipse.persistence.oxm.mappings.XMLMapping, org.eclipse.persistence.internal.oxm.mappings.Mapping, org.eclipse.persistence.internal.oxm.mappings.AnyCollectionMapping, org.eclipse.persistence.internal.oxm.mappings.XMLConverterMapping, org.eclipse.persistence.internal.oxm.mappings.XMLContainerMapping
Imports
java.util.ArrayList, .Iterator, .Map, .Vector, javax.xml.namespace.QName, org.eclipse.persistence.descriptors.ClassDescriptor, org.eclipse.persistence.exceptions.DatabaseException, .DescriptorException, .XMLMarshalException, org.eclipse.persistence.internal.descriptors.DescriptorIterator, org.eclipse.persistence.internal.helper.DatabaseField, org.eclipse.persistence.internal.identitymaps.CacheKey, org.eclipse.persistence.internal.oxm.XMLObjectBuilder, .XPathEngine, .XPathFragment, org.eclipse.persistence.internal.oxm.mappings.AnyCollectionMapping, .XMLContainerMapping, org.eclipse.persistence.internal.queries.CollectionContainerPolicy, .ContainerPolicy, .JoinedAttributeManager, .ListContainerPolicy, org.eclipse.persistence.internal.sessions.AbstractRecord, .AbstractSession, .ChangeRecord, .MergeManager, .ObjectChangeSet, .UnitOfWorkImpl, org.eclipse.persistence.internal.sessions.remote.ObjectDescriptor, org.eclipse.persistence.mappings.AttributeAccessor, .ContainerMapping, .DatabaseMapping, org.eclipse.persistence.oxm.XMLConstants, .XMLContext, .XMLDescriptor, .XMLField, .XMLMarshaller, .XMLRoot, .XMLUnmarshaller, org.eclipse.persistence.oxm.mappings.converters.XMLConverter, org.eclipse.persistence.oxm.mappings.nullpolicy.AbstractNullPolicy, org.eclipse.persistence.oxm.record.DOMRecord, .XMLRecord, org.eclipse.persistence.platform.xml.XMLPlatform, .XMLPlatformFactory, org.eclipse.persistence.queries.ObjectBuildingQuery, .ObjectLevelReadQuery, org.eclipse.persistence.sessions.Session, org.eclipse.persistence.sessions.remote.DistributedSession, org.w3c.dom.Element, .Node, .NodeList, .Text

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 statements
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)

Field Summary

Modifier and TypeField and Description
private boolean
private ContainerPolicy
private boolean
private XMLField
private boolean
private boolean
private boolean
private boolean
private XMLConverter
private AbstractNullPolicy

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
buildBackupClone(Object
TODO
clone
,
Object
TODO
backup
,
UnitOfWorkImpl
TODO
unitOfWork
)

Implements abstract org.eclipse.persistence.mappings.DatabaseMapping.buildBackupClone.

INTERNAL: Clone the attribute from the clone and assign it to the backup.
public void
buildClone(Object
TODO
original
,
CacheKey
TODO
cacheKey
,
Object
TODO
clone
,
Integer
TODO
refreshCascade
,
AbstractSession
TODO
cloningSession
)

Implements abstract org.eclipse.persistence.mappings.DatabaseMapping.buildClone.

INTERNAL: Clone the attribute from the original and assign it to the clone.
public void
buildCloneFromRow(AbstractRecord
TODO
databaseRow
,
JoinedAttributeManager
TODO
joinManager
,
Object
TODO
clone
,
CacheKey
TODO
sharedCacheKey
,
ObjectBuildingQuery
TODO
sourceQuery
,
UnitOfWorkImpl
TODO
unitOfWork
,
AbstractSession
TODO
executionSession
)

Implements abstract org.eclipse.persistence.mappings.DatabaseMapping.buildCloneFromRow.

INTERNAL: A combination of readFromRowIntoObject and buildClone.
protected AbstractRecord
buildCompositeRow(Object attributeValue, AbstractSession session, XMLDescriptor referenceDescriptor, AbstractRecord parentRow, DatabaseField field, Object originalObject, boolean wasXMLRoot)

private Object
public void
cascadePerformRemoveIfRequired(Object
TODO
object
,
UnitOfWorkImpl
TODO
uow
,
Map<K, V>
TODO
visitedObjects
)

Implements abstract org.eclipse.persistence.mappings.DatabaseMapping.cascadePerformRemoveIfRequired.

INTERNAL: Cascade perform delete through mappings that require the cascade
public void
cascadeRegisterNewIfRequired(Object
TODO
object
,
UnitOfWorkImpl
TODO
uow
,
Map<K, V>
TODO
visitedObjects
)

Implements abstract org.eclipse.persistence.mappings.DatabaseMapping.cascadeRegisterNewIfRequired.

INTERNAL: Cascade registerNew for Create through mappings that require the cascade
public Object
public ChangeRecord

Returns:

prototype.changeset.ChangeRecord
compareForChange
(Object
TODO
clone
,
Object
TODO
backup
,
ObjectChangeSet
TODO
owner
,
AbstractSession
TODO
session
)

Implements abstract org.eclipse.persistence.mappings.DatabaseMapping.compareForChange.

INTERNAL: This method was created in VisualAge.
public boolean
compareObjects(Object
TODO
firstObject
,
Object
TODO
secondObject
,
AbstractSession
TODO
session
)

Implements abstract org.eclipse.persistence.mappings.DatabaseMapping.compareObjects.

INTERNAL: Compare the attributes belonging to this mapping for the objects.
public Object
public Object
public void
fixObjectReferences(Object
TODO
object
,
Map<Object, ObjectDescriptor>
TODO
objectDescriptors
,
Map<Object, Object>
TODO
processedObjects
,
ObjectLevelReadQuery
TODO
query
,
DistributedSession
TODO
session
)

Implements abstract org.eclipse.persistence.mappings.DatabaseMapping.fixObjectReferences.

INTERNAL: An object has been serialized from the server to the client.
public ContainerPolicy
public XMLConverter
public DatabaseField
getField()

Overrides org.eclipse.persistence.mappings.DatabaseMapping.getField.

Implements org.eclipse.persistence.internal.oxm.mappings.Mapping.getField.

INTERNAL: Return the field associated with this mapping if there is exactly one.
public Vector<E>
getFields()

Overrides org.eclipse.persistence.mappings.DatabaseMapping.getFields.

INTERNAL: Returns a vector of all the fields this mapping represents.
private XPathFragment<XML_FIELD extends Field>
public boolean
getReuseContainer()

Implements org.eclipse.persistence.internal.oxm.mappings.XMLContainerMapping.getReuseContainer.

Return true if the original container on the object should be used if present.
private ArrayList<E>
public AbstractNullPolicy
public void
initialize(AbstractSession session)

Overrides org.eclipse.persistence.mappings.DatabaseMapping.initialize.

INTERNAL: Allow for initialization of properties and validation.
public boolean
public boolean
isDefaultEmptyContainer()

Implements org.eclipse.persistence.internal.oxm.mappings.XMLContainerMapping.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.
public boolean
private boolean
public boolean
isWhitespacePreservedForMixedContent()

Implements org.eclipse.persistence.internal.oxm.mappings.AnyCollectionMapping.isWhitespacePreservedForMixedContent.

Setting this to true indicates that text nodes containing *only* whitespaces should still be added to the collection as strings for mixed content.
public boolean
isXMLMapping()

Overrides org.eclipse.persistence.mappings.DatabaseMapping.isXMLMapping.

INTERNAL: All relational mappings should implement this method to return true.
public void
iterate(DescriptorIterator iterator)

Implements abstract org.eclipse.persistence.mappings.DatabaseMapping.iterate.

INTERNAL: Iterate on the appropriate attribute value.
public void
mergeChangesIntoObject(Object target, ChangeRecord changeRecord, Object source, MergeManager mergeManager, AbstractSession targetSession)

Implements abstract org.eclipse.persistence.mappings.DatabaseMapping.mergeChangesIntoObject.

INTERNAL: Merge changes from the source to the target object.
public void
mergeIntoObject(Object target, boolean isTargetUninitialized, Object source, MergeManager mergeManager, AbstractSession targetSession)

Implements abstract org.eclipse.persistence.mappings.DatabaseMapping.mergeIntoObject.

INTERNAL: Merge changes from the source to the target object.
public void
public void
public void
setDefaultEmptyContainer(boolean defaultEmptyContainer)

Implements org.eclipse.persistence.internal.oxm.mappings.XMLContainerMapping.setDefaultEmptyContainer.

INTERNAL Indicate whether by default an empty container should be set on the field/property if the collection is not present in the XML document.
public void
public void
public void
public void
setReuseContainer(boolean reuseContainer)

Implements org.eclipse.persistence.internal.oxm.mappings.XMLContainerMapping.setReuseContainer.

Specify whether the original container on the object should be used if present.
public void
public void
public void
public void
useCollectionClass(Class<?> concreteContainerClass)

Implements org.eclipse.persistence.internal.oxm.mappings.AnyCollectionMapping.useCollectionClass, org.eclipse.persistence.mappings.ContainerMapping.useCollectionClass.

PUBLIC: Configure the mapping to use an instance of the specified container class to hold the target objects.
public void
useCollectionClassName(String concreteContainerClassName)

Implements org.eclipse.persistence.mappings.ContainerMapping.useCollectionClassName.

PUBLIC: Configure the mapping to use an instance of the specified container class to hold the target objects.
public void
useListClassName(String concreteContainerClassName)

Implements org.eclipse.persistence.mappings.ContainerMapping.useListClassName.

PUBLIC: Configure the mapping to use an instance of the specified container class to hold the target objects.
public void
useMapClass(Class<?> concreteContainerClass, String methodName)

Implements org.eclipse.persistence.mappings.ContainerMapping.useMapClass.

PUBLIC: Configure the mapping to use an instance of the specified container class to hold the target objects.
public void
useMapClassName(String concreteContainerClass, String methodName)

Implements org.eclipse.persistence.mappings.ContainerMapping.useMapClassName.

PUBLIC: Configure the mapping to use an instance of the specified container class to hold the target objects.
public boolean
public Object
valueFromRow(AbstractRecord row, JoinedAttributeManager joinManager, ObjectBuildingQuery sourceQuery, CacheKey cacheKey, AbstractSession executionSession, boolean isTargetProtected, Boolean[] wasCacheUsed)

Overrides org.eclipse.persistence.mappings.DatabaseMapping.valueFromRow.

INTERNAL: A subclass should implement this method if it wants different behavior.
public void
writeFromObjectIntoRow(Object object, AbstractRecord row, AbstractSession session, DatabaseMapping.WriteType writeType)

Overrides org.eclipse.persistence.mappings.DatabaseMapping.writeFromObjectIntoRow.

INTERNAL: A subclass should implement this method if it wants different behavior.
private void
writeSimpleValue(XMLField xmlRootField, Object element, Object originalObject, DOMRecord record, Document doc, Node root, boolean wasXMLRoot, AbstractSession session)

public void
writeSingleValue(Object
- The value to be marshalled
element
,
Object parent, XMLRecord
- The Record the value is being marshalled too.
row
,
AbstractSession session)

Implements org.eclipse.persistence.internal.oxm.mappings.Mapping.writeSingleValue, org.eclipse.persistence.oxm.mappings.XMLMapping.writeSingleValue.

INTERNAL: A method that marshals a single value to the provided Record based on this mapping's XPath.
Inherited from org.eclipse.persistence.oxm.mappings.XMLAbstractAnyMapping:
buildObjectAndWrapInXMLRootbuildObjectForNonXMLRootbuildObjectNoReferenceDescriptorbuildXMLRootbuildXMLRootForTextgetDescriptorgetKeepAsElementPolicyisWriteOnlypreInitializesetAttributeValueInObjectsetIsWriteOnlysetKeepAsElementPolicy