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.
  • 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

      protected Map visitedObjects
    • visitedMappings

      protected Map<Integer,DatabaseMapping> visitedMappings
    • 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 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

      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()
    • getVisitedMappings

      public Map<Integer,DatabaseMapping> getVisitedMappings()
    • 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.
      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

      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.
      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

      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)