Top Description Inners Fields Constructors Methods
org.eclipse.persistence.internal.descriptors

public abstract Class DescriptorIterator

extends Object
Class Inheritance
Known Direct Subclasses
org.eclipse.persistence.internal.sessions.remote.ReplaceValueHoldersIterator
Imports
java.util.ArrayList, .HashSet, .IdentityHashMap, .List, .Map, .Set, .Stack, org.eclipse.persistence.descriptors.ClassDescriptor, org.eclipse.persistence.exceptions.DescriptorException, org.eclipse.persistence.indirection.IndirectCollection, .IndirectContainer, .ValueHolderInterface, org.eclipse.persistence.internal.queries.AttributeItem, org.eclipse.persistence.internal.sessions.AbstractSession, org.eclipse.persistence.mappings.DatabaseMapping, org.eclipse.persistence.queries.AttributeGroup, .FetchGroup

This class provides a generic way of using the descriptor information to traverse an object graph. Define a subclass, or an inner class, that implements at least #iterate(Object) to implement a new traversal feature without having to change the mapping classes or the object builder. It provides functionality such as a cascading depth, a stack of visited object, and a collection of the visited objects.

Note

If this works nicely the merge manager, remote traversals, and maybe even aspects of the commit manager could be converted to use this class.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public class

Field Summary

Modifier and TypeField and Description
public static final int
protected DescriptorIterator.CascadeCondition
protected int
public static final int
protected ClassDescriptor
protected AttributeGroup
protected AttributeItem
protected DatabaseMapping
protected boolean
public static final int
protected Object
protected AbstractSession
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
protected Map<K, V>
protected Stack<E>

Constructor Summary

AccessConstructor and Description
protected
DescriptorIterator()

Construct a typical iterator: iterate over all the objects process the objects contained by "value holders"...

Method Summary

Modifier and TypeMethod and Description
public int
public ClassDescriptor
public AttributeGroup
public AttributeItem
public DatabaseMapping
protected ClassDescriptor
getDescriptorFor(Object object)

Fetch and return the descriptor for the specified object.

public Object
public AbstractSession
public Object
getVisitedGrandparent()

Return the second-to-last object visited.

public Map<K, V>
public Object
getVisitedParent()

Return the last object visited.

public Stack<E>
protected void
internalIterateAggregateObject(Object aggregateObject)

Iterate an aggregate object (i.e. an object that is the target of an AggregateMapping).

protected void
internalIterateIndirectContainer(IndirectContainer<C> container)

Iterate an indirect container (IndirectList or IndirectMap).

protected void
internalIteratePrimitive(Object primitiveValue)

Iterate a primitive object (String, Date, Integer, etc.).

protected void
internalIterateReferenceObject(Object referenceObject)

Iterate a (a non-Aggregate) reference object.

protected void
protected void
internalIterateValueHolder(ValueHolderInterface<T> valueHolder)

Iterate a value holder.

public boolean
protected abstract void
iterate(Object object)

To define a new iterator create a subclass and define at least this method.

public void
iterateForAggregateMapping(Object aggregateObject, DatabaseMapping mapping, ClassDescriptor descriptor)

Iterate on the mapping's reference object and recursively iterate on the reference object's reference objects.

public void
iterateIndirectContainerForMapping(IndirectContainer<C> container, DatabaseMapping mapping)

Iterate on the indirection object for its mapping.

public void
iteratePrimitiveForMapping(Object primitiveValue, DatabaseMapping mapping)

Iterate on the primitive value for its mapping.

public void
iterateReferenceObjectForMapping(Object referenceObject, DatabaseMapping mapping)

Iterate on the mapping's reference object and recursively iterate on the reference object's reference objects.

protected void
iterateReferenceObjects(Object sourceObject)

Iterate over the sourceObject's reference objects, updating the visited stack appropriately.

public void
iterateValueHolderForMapping(ValueHolderInterface<T> valueHolder, DatabaseMapping mapping)

Iterate on the value holder for its mapping.

public void
public void
setCascadeDepth(int cascadeDepth)

public void
public void
public void
public void
public void
setForDetach(boolean forDetach)

public void
setResult(Object result)

public void
public void
setShouldBreak(boolean shouldBreak)

public void
setShouldIterateOnAggregates(boolean shouldIterateOnAggregates)

Set whether the aggregate reference objects themselves should be processed.

public void
setShouldIterateOnFetchGroupAttributesOnly(boolean shouldIterateOnFetchGroupAttributesOnly)

Set whether the attributes outside fetch group should be processed.

public void
setShouldIterateOnIndirectionObjects(boolean shouldIterateOnIndirectionObjects)

Set whether the indirection objects themselves (e.g. the ValueHolders) should be processed.

public void
setShouldIterateOnPrimitives(boolean shouldIterateOnPrimitives)

Set whether to process primitive reference objects (e.g. Strings, Dates, ints).

public void
setShouldIterateOverIndirectionObjects(boolean shouldIterateOverIndirectionObjects)

Set whether to process the objects contained by indirection objects (e.g. a ValueHolder's value) - but *without* instantiating them.

public void
setShouldIterateOverUninstantiatedIndirectionObjects(boolean shouldIterateOverUninstantiatedIndirectionObjects)

Set whether to *instantiate* and process the objects contained by indirection objects (e.g. a ValueHolder's value).

public void
setShouldIterateOverWrappedObjects(boolean shouldIterateOverWrappedObjects)

public void
setShouldTrackCurrentGroup(boolean shouldTrackCurrentGroup)

public void
setVisitedObjects(Map<K, V> visitedObjects)

protected void
setVisitedStack(Stack<E> visitedStack)

public boolean
public boolean
public boolean
public boolean
public boolean
shouldIterateOnAggregates()

Return whether the aggregate reference objects themselves should be processed.

public boolean
shouldIterateOnFetchGroupAttributesOnly()

If true then if object has a FetchGroup then iterations not performed on mappings that are outside of the FetchGroup.

public boolean
shouldIterateOnIndirectionObjects()

Return whether the indirection objects themselves (e.g. the ValueHolders) should be processed.

public boolean
shouldIterateOnPrimitives()

Return whether to process primitive reference objects (e.g. Strings, Dates, ints).

public boolean
shouldIterateOverIndirectionObjects()

Return whether to process the objects contained by indirection objects (e.g. a ValueHolder's value) - but *without* instantiating them.

public boolean
shouldIterateOverUninstantiatedIndirectionObjects()

Return whether to *instantiate* and process the objects contained by indirection objects (e.g. a ValueHolder's value).

public boolean
public boolean
public void
startIterationOn(Object sourceObject)

This is the root method called to start the iteration.

public void
startIterationOn(Object sourceObject, AttributeGroup group)

public boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CascadeAllPartsback to summary
public static final int CascadeAllParts
cascadeConditionback to summary
protected DescriptorIterator.CascadeCondition cascadeCondition
cascadeDepthback to summary
protected int cascadeDepth
CascadePrivatePartsback to summary
public static final int CascadePrivateParts
currentDescriptorback to summary
protected ClassDescriptor currentDescriptor
currentGroupback to summary
protected AttributeGroup currentGroup
currentItemback to summary
protected AttributeItem currentItem
currentMappingback to summary
protected DatabaseMapping currentMapping
forDetachback to summary
protected boolean forDetach
NoCascadingback to summary
public static final int NoCascading
resultback to summary
protected Object result
sessionback to summary
protected AbstractSession session
shouldBreakback to summary
protected boolean shouldBreak
shouldIterateOnAggregatesback to summary
protected boolean shouldIterateOnAggregates
shouldIterateOnFetchGroupAttributesOnlyback to summary
protected boolean shouldIterateOnFetchGroupAttributesOnly
shouldIterateOnIndirectionObjectsback to summary
protected boolean shouldIterateOnIndirectionObjects
shouldIterateOnPrimitivesback to summary
protected boolean shouldIterateOnPrimitives
shouldIterateOverIndirectionObjectsback to summary
protected boolean shouldIterateOverIndirectionObjects
shouldIterateOverUninstantiatedIndirectionObjectsback to summary
protected boolean shouldIterateOverUninstantiatedIndirectionObjects
shouldIterateOverWrappedObjectsback to summary
protected boolean shouldIterateOverWrappedObjects
shouldTrackCurrentGroupback to summary
protected boolean shouldTrackCurrentGroup
usesGroupback to summary
protected boolean usesGroup
visitedObjectsback to summary
protected Map<K, V> visitedObjects
visitedStackback to summary
protected Stack<E> visitedStack

Constructor Detail

DescriptorIteratorback to summary
protected DescriptorIterator()

Construct a typical iterator: iterate over all the objects process the objects contained by "value holders"... ...but only if they have already been instantiated... ...and don't process the "value holders" themselves process "wrapped" objects skip aggregate objects skip primitives (Strings, Dates, Integers, etc.)

Method Detail

getCascadeDepthback to summary
public int getCascadeDepth()
getCurrentDescriptorback to summary
public ClassDescriptor getCurrentDescriptor()
getCurrentGroupback to summary
public AttributeGroup getCurrentGroup()
getCurrentItemback to summary
public AttributeItem getCurrentItem()
getCurrentMappingback to summary
public DatabaseMapping getCurrentMapping()
getDescriptorForback to summary
protected ClassDescriptor getDescriptorFor(Object object)

Fetch and return the descriptor for the specified object.

getResultback to summary
public Object getResult()
getSessionback to summary
public AbstractSession getSession()
getVisitedGrandparentback to summary
public Object getVisitedGrandparent()

Return the second-to-last object visited.

getVisitedObjectsback to summary
public Map<K, V> getVisitedObjects()
getVisitedParentback to summary
public Object getVisitedParent()

Return the last object visited.

getVisitedStackback to summary
public Stack<E> getVisitedStack()
internalIterateAggregateObjectback to summary
protected void internalIterateAggregateObject(Object aggregateObject)

Iterate an aggregate object (i.e. an object that is the target of an AggregateMapping). Override this method if appropriate.

internalIterateIndirectContainerback to summary
protected void internalIterateIndirectContainer(IndirectContainer<C> container)

Iterate an indirect container (IndirectList or IndirectMap). Override this method if appropriate.

internalIteratePrimitiveback to summary
protected void internalIteratePrimitive(Object primitiveValue)

Iterate a primitive object (String, Date, Integer, etc.). Override this method if appropriate.

internalIterateReferenceObjectback to summary
protected void internalIterateReferenceObject(Object referenceObject)

Iterate a (a non-Aggregate) reference object. Override this method if appropriate.

internalIterateReferenceObjectsback to summary
protected void internalIterateReferenceObjects(Object sourceObject)
internalIterateValueHolderback to summary
protected void internalIterateValueHolder(ValueHolderInterface<T> valueHolder)

Iterate a value holder. Override this method if appropriate.

isForDetachback to summary
public boolean isForDetach()
iterateback to summary
protected abstract void iterate(Object object)

To define a new iterator create a subclass and define at least this method. Given an object or set of the objects, this method will be called on those objects and any object connected to them by using the descriptors to traverse the object graph. Override the assorted #internalIterate*() methods if appropriate.

iterateForAggregateMappingback to summary
public void iterateForAggregateMapping(Object aggregateObject, DatabaseMapping mapping, ClassDescriptor descriptor)

Iterate on the mapping's reference object and recursively iterate on the reference object's reference objects. This is used for aggregate and aggregate collection mappings, which are not iterated on by default.

iterateIndirectContainerForMappingback to summary
public void iterateIndirectContainerForMapping(IndirectContainer<C> container, DatabaseMapping mapping)

Iterate on the indirection object for its mapping.

iteratePrimitiveForMappingback to summary
public void iteratePrimitiveForMapping(Object primitiveValue, DatabaseMapping mapping)

Iterate on the primitive value for its mapping.

iterateReferenceObjectForMappingback to summary
public void iterateReferenceObjectForMapping(Object referenceObject, DatabaseMapping mapping)

Iterate on the mapping's reference object and recursively iterate on the reference object's reference objects.

iterateReferenceObjectsback to summary
protected void iterateReferenceObjects(Object sourceObject)

Iterate over the sourceObject's reference objects, updating the visited stack appropriately.

iterateValueHolderForMappingback to summary
public void iterateValueHolderForMapping(ValueHolderInterface<T> valueHolder, DatabaseMapping mapping)

Iterate on the value holder for its mapping.

setCascadeConditionback to summary
public void setCascadeCondition(DescriptorIterator.CascadeCondition cascadeCondition)
setCascadeDepthback to summary
public void setCascadeDepth(int cascadeDepth)
setCurrentDescriptorback to summary
public void setCurrentDescriptor(ClassDescriptor currentDescriptor)
setCurrentGroupback to summary
public void setCurrentGroup(AttributeGroup group)
setCurrentItemback to summary
public void setCurrentItem(AttributeItem item)
setCurrentMappingback to summary
public void setCurrentMapping(DatabaseMapping currentMapping)
setForDetachback to summary
public void setForDetach(boolean forDetach)
setResultback to summary
public void setResult(Object result)
setSessionback to summary
public void setSession(AbstractSession session)
setShouldBreakback to summary
public void setShouldBreak(boolean shouldBreak)
setShouldIterateOnAggregatesback to summary
public void setShouldIterateOnAggregates(boolean shouldIterateOnAggregates)

Set whether the aggregate reference objects themselves should be processed. (The objects referenced by the aggregate objects will be processed either way.)

setShouldIterateOnFetchGroupAttributesOnlyback to summary
public void setShouldIterateOnFetchGroupAttributesOnly(boolean shouldIterateOnFetchGroupAttributesOnly)

Set whether the attributes outside fetch group should be processed.

setShouldIterateOnIndirectionObjectsback to summary
public void setShouldIterateOnIndirectionObjects(boolean shouldIterateOnIndirectionObjects)

Set whether the indirection objects themselves (e.g. the ValueHolders) should be processed.

setShouldIterateOnPrimitivesback to summary
public void setShouldIterateOnPrimitives(boolean shouldIterateOnPrimitives)

Set whether to process primitive reference objects (e.g. Strings, Dates, ints).

setShouldIterateOverIndirectionObjectsback to summary
public void setShouldIterateOverIndirectionObjects(boolean shouldIterateOverIndirectionObjects)

Set whether to process the objects contained by indirection objects (e.g. a ValueHolder's value) - but *without* instantiating them.

See Also
setShouldIterateOverUninstantiatedIndirectionObjects(boolean)
setShouldIterateOverUninstantiatedIndirectionObjectsback to summary
public void setShouldIterateOverUninstantiatedIndirectionObjects(boolean shouldIterateOverUninstantiatedIndirectionObjects)

Set whether to *instantiate* and process the objects contained by indirection objects (e.g. a ValueHolder's value).

setShouldIterateOverWrappedObjectsback to summary
public void setShouldIterateOverWrappedObjects(boolean shouldIterateOverWrappedObjects)
setShouldTrackCurrentGroupback to summary
public void setShouldTrackCurrentGroup(boolean shouldTrackCurrentGroup)
setVisitedObjectsback to summary
public void setVisitedObjects(Map<K, V> visitedObjects)
setVisitedStackback to summary
protected void setVisitedStack(Stack<E> visitedStack)
shouldBreakback to summary
public boolean shouldBreak()
shouldCascadeAllPartsback to summary
public boolean shouldCascadeAllParts()
shouldCascadeNoPartsback to summary
public boolean shouldCascadeNoParts()
shouldCascadePrivatePartsback to summary
public boolean shouldCascadePrivateParts()
shouldIterateOnAggregatesback to summary
public boolean shouldIterateOnAggregates()

Return whether the aggregate reference objects themselves should be processed. (The objects referenced by the aggregate objects will be processed either way.)

shouldIterateOnFetchGroupAttributesOnlyback to summary
public boolean shouldIterateOnFetchGroupAttributesOnly()

If true then if object has a FetchGroup then iterations not performed on mappings that are outside of the FetchGroup.

shouldIterateOnIndirectionObjectsback to summary
public boolean shouldIterateOnIndirectionObjects()

Return whether the indirection objects themselves (e.g. the ValueHolders) should be processed.

shouldIterateOnPrimitivesback to summary
public boolean shouldIterateOnPrimitives()

Return whether to process primitive reference objects (e.g. Strings, Dates, ints).

shouldIterateOverIndirectionObjectsback to summary
public boolean shouldIterateOverIndirectionObjects()

Return whether to process the objects contained by indirection objects (e.g. a ValueHolder's value) - but *without* instantiating them.

See Also
shouldIterateOverUninstantiatedIndirectionObjects()
shouldIterateOverUninstantiatedIndirectionObjectsback to summary
public boolean shouldIterateOverUninstantiatedIndirectionObjects()

Return whether to *instantiate* and process the objects contained by indirection objects (e.g. a ValueHolder's value).

shouldIterateOverWrappedObjectsback to summary
public boolean shouldIterateOverWrappedObjects()
shouldTrackCurrentGroupback to summary
public boolean shouldTrackCurrentGroup()
startIterationOnback to summary
public void startIterationOn(Object sourceObject)

This is the root method called to start the iteration.

startIterationOnback to summary
public void startIterationOn(Object sourceObject, AttributeGroup group)
usesGroupback to summary
public boolean usesGroup()
org.eclipse.persistence.internal.descriptors back to summary

public Class DescriptorIterator.CascadeCondition

extends Object
Class Inheritance
  • java.lang.Object
  • org.eclipse.persistence.internal.descriptors.DescriptorIterator.CascadeCondition

Constructor Summary

AccessConstructor and Description
public
CascadeCondition()

Default constructor.

Method Summary

Modifier and TypeMethod and Description
public boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

CascadeConditionback to summary
public CascadeCondition()

Default constructor.

Method Detail

shouldNotCascadeback to summary
public boolean shouldNotCascade(DatabaseMapping mapping)