public abstract class

AbstractVisitResults

extends Object
implements IVisitResults<T>
java.lang.Object
   ↳ com.pnfsoftware.jeb.core.units.code.AbstractVisitResults<T>
Known Direct Subclasses

Class Overview

Skeleton implementation for visit result objects.

Summary

[Expand]
Inherited Constants
From interface com.pnfsoftware.jeb.core.units.code.IVisitResults
Fields
public T currentNode for DFS pre-order only
public Deque<T> parents optional queue used to record parents; non-null only if FLAG_RECORD_PARENTS was used when creating the object
public boolean skipAssignmentDestination
public boolean skipVisitingChildren for DFS pre-order only
public int visitedChildPosition Internal indicator field regarding the position of the visited child within its parent node.
Public Constructors
AbstractVisitResults()
AbstractVisitResults(int flags)
Public Methods
int getFlags()
int getResultCode()
void interrupt(boolean success, int code)
Notify the visitor that the visit of the tree should be stopped.
void interrupt(boolean success)
Notify the visitor that the visit of the tree should be stopped.
boolean isInterruptedVisit()
boolean isVisitedSuccessfully()
T parent(int index)
This convenience method returns the i'th ancestor (i=0 being the immediate parent) of the element.
Iterator<T> parentsIterator()
Optional iterator containing the parents; non-null only if FLAG_RECORD_PARENTS was used when creating the object.
void popParent()
void pushParent(T parent)
void setReplacedNode(T newNode)
Notify the visitor that the current node was replaced by the process method.
void setVisitResult(boolean success)
Saves the visit result (do not stop the visitor: use interrupt(boolean) to stop the process)
void skipChildren()
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.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.pnfsoftware.jeb.core.units.code.IVisitResults

Fields

public T currentNode

for DFS pre-order only

public Deque<T> parents

optional queue used to record parents; non-null only if FLAG_RECORD_PARENTS was used when creating the object

public boolean skipAssignmentDestination

public boolean skipVisitingChildren

for DFS pre-order only

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.

Public Constructors

public AbstractVisitResults ()

public AbstractVisitResults (int flags)

Public Methods

public int getFlags ()

public int getResultCode ()

public void interrupt (boolean success, int code)

Notify the visitor that the visit of the tree should be stopped.

Parameters
success visit result
code optional code, can be retrieved via getResultCode()

public void interrupt (boolean success)

Notify the visitor that the visit of the tree should be stopped.

Parameters
success the result of the visit

public boolean isInterruptedVisit ()

public boolean isVisitedSuccessfully ()

public T parent (int index)

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

Parameters
index parent index, negative indices are allowed (-1 means the highest ancestor)
Returns
  • the requested parent or null

public Iterator<T> parentsIterator ()

Optional iterator containing the parents; non-null only if 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.

public void popParent ()

public void pushParent (T parent)

public void setReplacedNode (T newNode)

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.

Parameters
newNode the non-null new node

public void setVisitResult (boolean success)

Saves the visit result (do not stop the visitor: use interrupt(boolean) to stop the process)

public void skipChildren ()

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.