Class DescriptorIterator
- java.lang.Object
-
- org.eclipse.persistence.internal.descriptors.DescriptorIterator
-
- Direct Known Subclasses:
ReplaceValueHoldersIterator
public abstract class DescriptorIterator extends Object
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 Modifier and Type Class Description class
DescriptorIterator.CascadeCondition
-
Field Summary
Fields Modifier and Type Field Description static int
CascadeAllParts
protected DescriptorIterator.CascadeCondition
cascadeCondition
protected int
cascadeDepth
static int
CascadePrivateParts
protected ClassDescriptor
currentDescriptor
protected AttributeGroup
currentGroup
protected AttributeItem
currentItem
protected DatabaseMapping
currentMapping
protected boolean
forDetach
static int
NoCascading
protected Object
result
protected AbstractSession
session
protected boolean
shouldBreak
protected boolean
shouldIterateOnAggregates
protected boolean
shouldIterateOnFetchGroupAttributesOnly
protected boolean
shouldIterateOnIndirectionObjects
protected boolean
shouldIterateOnPrimitives
protected boolean
shouldIterateOverIndirectionObjects
protected boolean
shouldIterateOverUninstantiatedIndirectionObjects
protected boolean
shouldIterateOverWrappedObjects
protected boolean
shouldTrackCurrentGroup
protected boolean
usesGroup
protected Map
visitedObjects
protected Stack
visitedStack
-
Constructor Summary
Constructors Constructor Description DescriptorIterator()
Construct a typical iterator: iterate over all the objects process the objects contained by "value holders"...
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
getCascadeDepth()
ClassDescriptor
getCurrentDescriptor()
AttributeGroup
getCurrentGroup()
AttributeItem
getCurrentItem()
DatabaseMapping
getCurrentMapping()
protected ClassDescriptor
getDescriptorFor(Object object)
Fetch and return the descriptor for the specified object.Object
getResult()
AbstractSession
getSession()
Object
getVisitedGrandparent()
Return the second-to-last object visited.Map
getVisitedObjects()
Object
getVisitedParent()
Return the last object visited.Stack
getVisitedStack()
protected void
internalIterateAggregateObject(Object aggregateObject)
Iterate an aggregate object (i.e.protected void
internalIterateIndirectContainer(IndirectContainer 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
internalIterateReferenceObjects(Object sourceObject)
protected void
internalIterateValueHolder(ValueHolderInterface valueHolder)
Iterate a value holder.boolean
isForDetach()
protected abstract void
iterate(Object object)
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
setResult(Object result)
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
shouldBreak()
boolean
shouldCascadeAllParts()
boolean
shouldCascadeNoParts()
boolean
shouldCascadePrivateParts()
boolean
shouldIterateOnAggregates()
Return whether the aggregate reference objects themselves should be processed.boolean
shouldIterateOnFetchGroupAttributesOnly()
If true then if object has a FetchGroup then iterations not performed on mappings that are outside of the FetchGroup.boolean
shouldIterateOnIndirectionObjects()
Return whether the indirection objects themselves (e.g.boolean
shouldIterateOnPrimitives()
Return whether to process primitive reference objects (e.g.boolean
shouldIterateOverIndirectionObjects()
Return whether to process the objects contained by indirection objects (e.g.boolean
shouldIterateOverUninstantiatedIndirectionObjects()
Return whether to *instantiate* and process the objects contained by indirection objects (e.g.boolean
shouldIterateOverWrappedObjects()
boolean
shouldTrackCurrentGroup()
void
startIterationOn(Object sourceObject)
This is the root method called to start the iteration.void
startIterationOn(Object sourceObject, AttributeGroup group)
boolean
usesGroup()
-
-
-
Field Detail
-
NoCascading
public static final int NoCascading
- See Also:
- Constant Field Values
-
CascadePrivateParts
public static final int CascadePrivateParts
- See Also:
- Constant Field Values
-
CascadeAllParts
public static final int CascadeAllParts
- See Also:
- Constant Field Values
-
visitedObjects
protected Map visitedObjects
-
visitedStack
protected Stack visitedStack
-
session
protected AbstractSession session
-
currentMapping
protected DatabaseMapping currentMapping
-
currentDescriptor
protected ClassDescriptor currentDescriptor
-
currentItem
protected AttributeItem currentItem
-
currentGroup
protected AttributeGroup currentGroup
-
usesGroup
protected boolean usesGroup
-
shouldTrackCurrentGroup
protected boolean shouldTrackCurrentGroup
-
result
protected Object 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
protected DescriptorIterator.CascadeCondition cascadeCondition
-
forDetach
protected boolean forDetach
-
-
Constructor Detail
-
DescriptorIterator
public 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
-
getCascadeDepth
public int getCascadeDepth()
-
getCurrentDescriptor
public ClassDescriptor getCurrentDescriptor()
-
getCurrentMapping
public DatabaseMapping getCurrentMapping()
-
getCurrentItem
public AttributeItem getCurrentItem()
-
getCurrentGroup
public AttributeGroup getCurrentGroup()
-
getDescriptorFor
protected ClassDescriptor getDescriptorFor(Object object)
Fetch and return the descriptor for the specified object.
-
getResult
public Object getResult()
-
getSession
public AbstractSession getSession()
-
getVisitedGrandparent
public Object getVisitedGrandparent()
Return the second-to-last object visited.
-
getVisitedObjects
public Map getVisitedObjects()
-
getVisitedParent
public Object getVisitedParent()
Return the last object visited.
-
getVisitedStack
public Stack getVisitedStack()
-
internalIterateAggregateObject
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.
-
internalIterateIndirectContainer
protected void internalIterateIndirectContainer(IndirectContainer container)
Iterate an indirect container (IndirectList or IndirectMap). Override this method if appropriate.
-
internalIteratePrimitive
protected void internalIteratePrimitive(Object primitiveValue)
Iterate a primitive object (String, Date, Integer, etc.). Override this method if appropriate.
-
internalIterateReferenceObject
protected void internalIterateReferenceObject(Object referenceObject)
Iterate a (a non-Aggregate) reference object. Override this method if appropriate.
-
internalIterateValueHolder
protected void internalIterateValueHolder(ValueHolderInterface valueHolder)
Iterate a value holder. Override this method if appropriate.
-
iterate
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.
-
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
public void iteratePrimitiveForMapping(Object primitiveValue, DatabaseMapping mapping)
Iterate on the primitive value for its mapping.
-
iterateReferenceObjectForMapping
public void iterateReferenceObjectForMapping(Object referenceObject, DatabaseMapping mapping)
Iterate on the mapping's reference object and recursively iterate on the reference object's reference objects.
-
iterateReferenceObjects
protected void iterateReferenceObjects(Object sourceObject)
Iterate over the sourceObject's reference objects, updating the visited stack appropriately.
-
internalIterateReferenceObjects
protected void internalIterateReferenceObjects(Object sourceObject)
-
iterateValueHolderForMapping
public void iterateValueHolderForMapping(ValueHolderInterface valueHolder, DatabaseMapping mapping)
Iterate on the value holder for its mapping.
-
setCascadeDepth
public void setCascadeDepth(int cascadeDepth)
-
setCascadeCondition
public void setCascadeCondition(DescriptorIterator.CascadeCondition cascadeCondition)
-
setCurrentDescriptor
public void setCurrentDescriptor(ClassDescriptor currentDescriptor)
-
setCurrentMapping
public void setCurrentMapping(DatabaseMapping currentMapping)
-
setCurrentItem
public void setCurrentItem(AttributeItem item)
-
setCurrentGroup
public void setCurrentGroup(AttributeGroup group)
-
setResult
public void setResult(Object result)
-
setSession
public void setSession(AbstractSession session)
-
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.
-
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
public void setVisitedObjects(Map visitedObjects)
-
setVisitedStack
protected void setVisitedStack(Stack visitedStack)
-
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.
-
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
public void startIterationOn(Object sourceObject)
This is the root method called to start the iteration.
-
startIterationOn
public void startIterationOn(Object sourceObject, AttributeGroup group)
-
isForDetach
public boolean isForDetach()
-
setForDetach
public void setForDetach(boolean forDetach)
-
-