Module org.eclipse.persistence.core
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 classDescriptorIterator.CascadeCondition
-
Field Summary
Fields Modifier and Type Field Description static intCascadeAllPartsprotected DescriptorIterator.CascadeConditioncascadeConditionprotected intcascadeDepthstatic intCascadePrivatePartsprotected ClassDescriptorcurrentDescriptorprotected AttributeGroupcurrentGroupprotected AttributeItemcurrentItemprotected DatabaseMappingcurrentMappingprotected booleanforDetachstatic intNoCascadingprotected Objectresultprotected AbstractSessionsessionprotected booleanshouldBreakprotected booleanshouldIterateOnAggregatesprotected booleanshouldIterateOnFetchGroupAttributesOnlyprotected booleanshouldIterateOnIndirectionObjectsprotected booleanshouldIterateOnPrimitivesprotected booleanshouldIterateOverIndirectionObjectsprotected booleanshouldIterateOverUninstantiatedIndirectionObjectsprotected booleanshouldIterateOverWrappedObjectsprotected booleanshouldTrackCurrentGroupprotected booleanusesGroupprotected MapvisitedObjectsprotected StackvisitedStack
-
Constructor Summary
Constructors Modifier Constructor Description protectedDescriptorIterator()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 intgetCascadeDepth()ClassDescriptorgetCurrentDescriptor()AttributeGroupgetCurrentGroup()AttributeItemgetCurrentItem()DatabaseMappinggetCurrentMapping()protected ClassDescriptorgetDescriptorFor(Object object)Fetch and return the descriptor for the specified object.ObjectgetResult()AbstractSessiongetSession()ObjectgetVisitedGrandparent()Return the second-to-last object visited.MapgetVisitedObjects()ObjectgetVisitedParent()Return the last object visited.StackgetVisitedStack()protected voidinternalIterateAggregateObject(Object aggregateObject)Iterate an aggregate object (i.e.protected voidinternalIterateIndirectContainer(IndirectContainer container)Iterate an indirect container (IndirectList or IndirectMap).protected voidinternalIteratePrimitive(Object primitiveValue)Iterate a primitive object (String, Date, Integer, etc.).protected voidinternalIterateReferenceObject(Object referenceObject)Iterate a (a non-Aggregate) reference object.protected voidinternalIterateReferenceObjects(Object sourceObject)protected voidinternalIterateValueHolder(ValueHolderInterface valueHolder)Iterate a value holder.booleanisForDetach()protected abstract voiditerate(Object object)To define a new iterator create a subclass and define at least this method.voiditerateForAggregateMapping(Object aggregateObject, DatabaseMapping mapping, ClassDescriptor descriptor)Iterate on the mapping's reference object and recursively iterate on the reference object's reference objects.voiditerateIndirectContainerForMapping(IndirectContainer container, DatabaseMapping mapping)Iterate on the indirection object for its mapping.voiditeratePrimitiveForMapping(Object primitiveValue, DatabaseMapping mapping)Iterate on the primitive value for its mapping.voiditerateReferenceObjectForMapping(Object referenceObject, DatabaseMapping mapping)Iterate on the mapping's reference object and recursively iterate on the reference object's reference objects.protected voiditerateReferenceObjects(Object sourceObject)Iterate over the sourceObject's reference objects, updating the visited stack appropriately.voiditerateValueHolderForMapping(ValueHolderInterface valueHolder, DatabaseMapping mapping)Iterate on the value holder for its mapping.voidsetCascadeCondition(DescriptorIterator.CascadeCondition cascadeCondition)voidsetCascadeDepth(int cascadeDepth)voidsetCurrentDescriptor(ClassDescriptor currentDescriptor)voidsetCurrentGroup(AttributeGroup group)voidsetCurrentItem(AttributeItem item)voidsetCurrentMapping(DatabaseMapping currentMapping)voidsetForDetach(boolean forDetach)voidsetResult(Object result)voidsetSession(AbstractSession session)voidsetShouldBreak(boolean shouldBreak)voidsetShouldIterateOnAggregates(boolean shouldIterateOnAggregates)Set whether the aggregate reference objects themselves should be processed.voidsetShouldIterateOnFetchGroupAttributesOnly(boolean shouldIterateOnFetchGroupAttributesOnly)Set whether the attributes outside fetch group should be processed.voidsetShouldIterateOnIndirectionObjects(boolean shouldIterateOnIndirectionObjects)Set whether the indirection objects themselves (e.g.voidsetShouldIterateOnPrimitives(boolean shouldIterateOnPrimitives)Set whether to process primitive reference objects (e.g.voidsetShouldIterateOverIndirectionObjects(boolean shouldIterateOverIndirectionObjects)Set whether to process the objects contained by indirection objects (e.g.voidsetShouldIterateOverUninstantiatedIndirectionObjects(boolean shouldIterateOverUninstantiatedIndirectionObjects)Set whether to *instantiate* and process the objects contained by indirection objects (e.g.voidsetShouldIterateOverWrappedObjects(boolean shouldIterateOverWrappedObjects)voidsetShouldTrackCurrentGroup(boolean shouldTrackCurrentGroup)voidsetVisitedObjects(Map visitedObjects)protected voidsetVisitedStack(Stack visitedStack)booleanshouldBreak()booleanshouldCascadeAllParts()booleanshouldCascadeNoParts()booleanshouldCascadePrivateParts()booleanshouldIterateOnAggregates()Return whether the aggregate reference objects themselves should be processed.booleanshouldIterateOnFetchGroupAttributesOnly()If true then if object has a FetchGroup then iterations not performed on mappings that are outside of the FetchGroup.booleanshouldIterateOnIndirectionObjects()Return whether the indirection objects themselves (e.g.booleanshouldIterateOnPrimitives()Return whether to process primitive reference objects (e.g.booleanshouldIterateOverIndirectionObjects()Return whether to process the objects contained by indirection objects (e.g.booleanshouldIterateOverUninstantiatedIndirectionObjects()Return whether to *instantiate* and process the objects contained by indirection objects (e.g.booleanshouldIterateOverWrappedObjects()booleanshouldTrackCurrentGroup()voidstartIterationOn(Object sourceObject)This is the root method called to start the iteration.voidstartIterationOn(Object sourceObject, AttributeGroup group)booleanusesGroup()
-
-
-
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
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
-
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)
-
-