Module org.eclipse.persistence.core
Class DescriptorIterator
java.lang.Object
org.eclipse.persistence.internal.descriptors.DescriptorIterator
- Direct Known Subclasses:
ReplaceValueHoldersIterator
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 Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
protected DescriptorIterator.CascadeCondition
protected int
static final int
protected ClassDescriptor
protected AttributeGroup
protected AttributeItem
protected DatabaseMapping
protected boolean
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
<Integer, DatabaseMapping> protected Map
protected Stack
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Construct a typical iterator: iterate over all the objects process the objects contained by "value holders"... -
Method Summary
Modifier and TypeMethodDescriptionint
protected ClassDescriptor
getDescriptorFor
(Object object) Fetch and return the descriptor for the specified object.Return the second-to-last object visited.Return the last object visited.protected void
internalIterateAggregateObject
(Object aggregateObject) Iterate an aggregate object (i.e.protected void
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
internalIterateReferenceObjects
(Object sourceObject) protected void
internalIterateValueHolder
(ValueHolderInterface valueHolder) Iterate a value holder.boolean
protected abstract void
To define a new iterator create a subclass and define at least this method.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.void
iterateIndirectContainerForMapping
(IndirectContainer container, DatabaseMapping mapping) Iterate on the indirection object for its mapping.void
iteratePrimitiveForMapping
(Object primitiveValue, DatabaseMapping mapping) Iterate on the primitive value for its mapping.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.void
iterateValueHolderForMapping
(ValueHolderInterface valueHolder, DatabaseMapping mapping) Iterate on the value holder for its mapping.void
setCascadeCondition
(DescriptorIterator.CascadeCondition cascadeCondition) void
setCascadeDepth
(int cascadeDepth) void
setCurrentDescriptor
(ClassDescriptor currentDescriptor) void
setCurrentGroup
(AttributeGroup group) void
setCurrentItem
(AttributeItem item) void
setCurrentMapping
(DatabaseMapping currentMapping) void
setForDetach
(boolean forDetach) void
void
setSession
(AbstractSession session) void
setShouldBreak
(boolean shouldBreak) void
setShouldIterateOnAggregates
(boolean shouldIterateOnAggregates) Set whether the aggregate reference objects themselves should be processed.void
setShouldIterateOnFetchGroupAttributesOnly
(boolean shouldIterateOnFetchGroupAttributesOnly) Set whether the attributes outside fetch group should be processed.void
setShouldIterateOnIndirectionObjects
(boolean shouldIterateOnIndirectionObjects) Set whether the indirection objects themselves (e.g.void
setShouldIterateOnPrimitives
(boolean shouldIterateOnPrimitives) Set whether to process primitive reference objects (e.g.void
setShouldIterateOverIndirectionObjects
(boolean shouldIterateOverIndirectionObjects) Set whether to process the objects contained by indirection objects (e.g.void
setShouldIterateOverUninstantiatedIndirectionObjects
(boolean shouldIterateOverUninstantiatedIndirectionObjects) Set whether to *instantiate* and process the objects contained by indirection objects (e.g.void
setShouldIterateOverWrappedObjects
(boolean shouldIterateOverWrappedObjects) void
setShouldTrackCurrentGroup
(boolean shouldTrackCurrentGroup) void
setVisitedObjects
(Map visitedObjects) protected void
setVisitedStack
(Stack visitedStack) boolean
boolean
boolean
boolean
boolean
Return whether the aggregate reference objects themselves should be processed.boolean
If true then if object has a FetchGroup then iterations not performed on mappings that are outside of the FetchGroup.boolean
Return whether the indirection objects themselves (e.g.boolean
Return whether to process primitive reference objects (e.g.boolean
Return whether to process the objects contained by indirection objects (e.g.boolean
Return whether to *instantiate* and process the objects contained by indirection objects (e.g.boolean
boolean
void
startIterationOn
(Object sourceObject) This is the root method called to start the iteration.void
startIterationOn
(Object sourceObject, AttributeGroup group) boolean
-
Field Details
-
NoCascading
public static final int NoCascading- See Also:
-
CascadePrivateParts
public static final int CascadePrivateParts- See Also:
-
CascadeAllParts
public static final int CascadeAllParts- See Also:
-
visitedObjects
-
visitedMappings
-
visitedStack
-
session
-
currentMapping
-
currentDescriptor
-
currentItem
-
currentGroup
-
usesGroup
protected boolean usesGroup -
shouldTrackCurrentGroup
protected boolean shouldTrackCurrentGroup -
result
-
shouldIterateOverIndirectionObjects
protected boolean shouldIterateOverIndirectionObjects -
shouldIterateOverUninstantiatedIndirectionObjects
protected boolean shouldIterateOverUninstantiatedIndirectionObjects -
shouldIterateOverWrappedObjects
protected boolean shouldIterateOverWrappedObjects -
shouldIterateOnIndirectionObjects
protected boolean shouldIterateOnIndirectionObjects -
shouldIterateOnAggregates
protected boolean shouldIterateOnAggregates -
shouldIterateOnPrimitives
protected boolean shouldIterateOnPrimitives -
shouldIterateOnFetchGroupAttributesOnly
protected boolean shouldIterateOnFetchGroupAttributesOnly -
shouldBreak
protected boolean shouldBreak -
cascadeDepth
protected int cascadeDepth -
cascadeCondition
-
forDetach
protected boolean forDetach
-
-
Constructor Details
-
DescriptorIterator
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 Details
-
getCascadeDepth
public int getCascadeDepth() -
getCurrentDescriptor
-
getCurrentMapping
-
getCurrentItem
-
getCurrentGroup
-
getDescriptorFor
Fetch and return the descriptor for the specified object. -
getResult
-
getSession
-
getVisitedGrandparent
Return the second-to-last object visited. -
getVisitedObjects
-
getVisitedMappings
-
getVisitedParent
Return the last object visited. -
getVisitedStack
-
internalIterateAggregateObject
Iterate an aggregate object (i.e. an object that is the target of an AggregateMapping). Override this method if appropriate. -
internalIterateIndirectContainer
Iterate an indirect container (IndirectList or IndirectMap). Override this method if appropriate. -
internalIteratePrimitive
Iterate a primitive object (String, Date, Integer, etc.). Override this method if appropriate. -
internalIterateReferenceObject
Iterate a (a non-Aggregate) reference object. Override this method if appropriate. -
internalIterateValueHolder
Iterate a value holder. Override this method if appropriate. -
iterate
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. -
iterateForAggregateMapping
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. -
iterateIndirectContainerForMapping
public void iterateIndirectContainerForMapping(IndirectContainer container, DatabaseMapping mapping) Iterate on the indirection object for its mapping. -
iteratePrimitiveForMapping
Iterate on the primitive value for its mapping. -
iterateReferenceObjectForMapping
Iterate on the mapping's reference object and recursively iterate on the reference object's reference objects. -
iterateReferenceObjects
Iterate over the sourceObject's reference objects, updating the visited stack appropriately. -
internalIterateReferenceObjects
-
iterateValueHolderForMapping
Iterate on the value holder for its mapping. -
setCascadeDepth
public void setCascadeDepth(int cascadeDepth) -
setCascadeCondition
-
setCurrentDescriptor
-
setCurrentMapping
-
setCurrentItem
-
setCurrentGroup
-
setResult
-
setSession
-
setShouldBreak
public void setShouldBreak(boolean shouldBreak) -
setShouldIterateOnAggregates
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.) -
setShouldIterateOnFetchGroupAttributesOnly
public void setShouldIterateOnFetchGroupAttributesOnly(boolean shouldIterateOnFetchGroupAttributesOnly) Set whether the attributes outside fetch group should be processed. -
setShouldIterateOnIndirectionObjects
public void setShouldIterateOnIndirectionObjects(boolean shouldIterateOnIndirectionObjects) Set whether the indirection objects themselves (e.g. the ValueHolders) should be processed. -
setShouldIterateOnPrimitives
public void setShouldIterateOnPrimitives(boolean shouldIterateOnPrimitives) Set whether to process primitive reference objects (e.g. Strings, Dates, ints). -
setShouldIterateOverIndirectionObjects
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
public void setShouldIterateOverUninstantiatedIndirectionObjects(boolean shouldIterateOverUninstantiatedIndirectionObjects) Set whether to *instantiate* and process the objects contained by indirection objects (e.g. a ValueHolder's value). -
setShouldIterateOverWrappedObjects
public void setShouldIterateOverWrappedObjects(boolean shouldIterateOverWrappedObjects) -
setShouldTrackCurrentGroup
public void setShouldTrackCurrentGroup(boolean shouldTrackCurrentGroup) -
setVisitedObjects
-
setVisitedStack
-
shouldBreak
public boolean shouldBreak() -
shouldCascadeAllParts
public boolean shouldCascadeAllParts() -
shouldCascadeNoParts
public boolean shouldCascadeNoParts() -
shouldCascadePrivateParts
public boolean shouldCascadePrivateParts() -
shouldIterateOnAggregates
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.) -
shouldIterateOnFetchGroupAttributesOnly
public boolean shouldIterateOnFetchGroupAttributesOnly()If true then if object has a FetchGroup then iterations not performed on mappings that are outside of the FetchGroup. -
shouldIterateOnIndirectionObjects
public boolean shouldIterateOnIndirectionObjects()Return whether the indirection objects themselves (e.g. the ValueHolders) should be processed. -
shouldIterateOnPrimitives
public boolean shouldIterateOnPrimitives()Return whether to process primitive reference objects (e.g. Strings, Dates, ints). -
shouldIterateOverIndirectionObjects
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
public boolean shouldIterateOverUninstantiatedIndirectionObjects()Return whether to *instantiate* and process the objects contained by indirection objects (e.g. a ValueHolder's value). -
shouldIterateOverWrappedObjects
public boolean shouldIterateOverWrappedObjects() -
shouldTrackCurrentGroup
public boolean shouldTrackCurrentGroup() -
usesGroup
public boolean usesGroup() -
startIterationOn
This is the root method called to start the iteration. -
startIterationOn
-
isForDetach
public boolean isForDetach() -
setForDetach
public void setForDetach(boolean forDetach)
-