Class AbstractVisitResults<T>

java.lang.Object
com.pnfsoftware.jeb.core.units.code.AbstractVisitResults<T>
All Implemented Interfaces:
IVisitResults<T>
Direct Known Subclasses:
CVisitResults, DVisitResults, EVisitResults, JVisitResults

public abstract class AbstractVisitResults<T> extends Object implements IVisitResults<T>
Skeleton implementation for visit result objects.
  • Field Details

    • skipAssignmentDestination

      public boolean skipAssignmentDestination
    • skipVisitingChildren

      public boolean skipVisitingChildren
      for DFS pre-order only
    • currentNode

      public T currentNode
      for DFS pre-order only
    • visitedChildPosition

      public int visitedChildPosition
      Internal indicator field regarding the position of the visited child within its parent node. This field may not be set, third-party code should not rely on it.
    • parents

      public Deque<T> parents
      optional queue used to record parents; non-null only if IVisitResults.FLAG_RECORD_PARENTS was used when creating the object
  • Constructor Details

    • AbstractVisitResults

      public AbstractVisitResults()
    • AbstractVisitResults

      public AbstractVisitResults(int flags)
  • Method Details

    • getFlags

      public int getFlags()
    • pushParent

      public void pushParent(T parent)
    • popParent

      public void popParent()
    • parentsIterator

      public Iterator<T> parentsIterator()
      Description copied from interface: IVisitResults
      Optional iterator containing the parents; non-null only if IVisitResults.FLAG_RECORD_PARENTS was used when creating the object. The first element provided by the iterator is the parent of the currently visited element; the last element is the deepest ancestor.
      Specified by:
      parentsIterator in interface IVisitResults<T>
    • parent

      public T parent(int index)
      Description copied from interface: IVisitResults
      This convenience method returns the i'th ancestor (i=0 being the immediate parent) of the element. On error, the method returns null (it never throws).
      Specified by:
      parent in interface IVisitResults<T>
      Parameters:
      index - parent index, negative indices are allowed (-1 means the highest ancestor)
      Returns:
      the requested parent or null
    • interrupt

      public void interrupt(boolean success)
      Description copied from interface: IVisitResults
      Notify the visitor that the visit of the tree should be stopped.
      Specified by:
      interrupt in interface IVisitResults<T>
      Parameters:
      success - the result of the visit
    • interrupt

      public void interrupt(boolean success, int code)
      Description copied from interface: IVisitResults
      Notify the visitor that the visit of the tree should be stopped.
      Specified by:
      interrupt in interface IVisitResults<T>
      Parameters:
      success - visit result
      code - optional code, can be retrieved via IVisitResults.getResultCode()
    • isInterruptedVisit

      public boolean isInterruptedVisit()
      Specified by:
      isInterruptedVisit in interface IVisitResults<T>
      Returns:
    • setVisitResult

      public void setVisitResult(boolean success)
      Description copied from interface: IVisitResults
      Saves the visit result (do not stop the visitor: use IVisitResults.interrupt(boolean) to stop the process)
      Specified by:
      setVisitResult in interface IVisitResults<T>
    • isVisitedSuccessfully

      public boolean isVisitedSuccessfully()
      Specified by:
      isVisitedSuccessfully in interface IVisitResults<T>
      Returns:
    • getResultCode

      public int getResultCode()
      Specified by:
      getResultCode in interface IVisitResults<T>
      Returns:
    • skipChildren

      public void skipChildren()
      Description copied from interface: IVisitResults
      Used in DFS pre-order to notify the visitor that the children of the currently visited node should be skipped; the visitor will then proceed with the next cousin.

      Note: this method is useless in DFS post-order since children of a node are always processed before their parent.

      Specified by:
      skipChildren in interface IVisitResults<T>
    • setReplacedNode

      public void setReplacedNode(T newNode)
      Description copied from interface: IVisitResults
      Notify the visitor that the current node was replaced by the process method.

      Note: usage of this method is not mandatory in a DFS post-order traversal.

      Specified by:
      setReplacedNode in interface IVisitResults<T>
      Parameters:
      newNode - the non-null new node