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
Skeleton implementation for visit result objects.
-
Field Summary
FieldsModifier and TypeFieldDescriptionfor DFS pre-order onlyoptional queue used to record parents; non-null only ifIVisitResults.FLAG_RECORD_PARENTSwas used when creating the objectbooleanbooleanfor DFS pre-order onlyintInternal indicator field regarding the position of the visited child within its parent node.Fields inherited from interface com.pnfsoftware.jeb.core.units.code.IVisitResults
FLAG_RECORD_PARENTS, FLAG_SKIP_ASSIGN_DST -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintgetFlags()intgetValue()voidinterrupt(boolean success) Notify the visitor that the visit of the tree should be stopped.voidinterrupt(boolean success, int forcedValue) Notify the visitor that the visit of the tree should be stopped.booleanbooleanparent(int index) This convenience method returns the i'th ancestor (i=0 being the immediate parent) of the element.Optional iterator containing the parents; non-null only ifIVisitResults.FLAG_RECORD_PARENTSwas used when creating the object.voidvoidpushParent(T parent) voidsetReplacedNode(T newNode) Notify the visitor that the current node was replaced by theprocessmethod.voidsetValue(int v) voidsetVisitResult(boolean success) Saves the visit result (do not stop the visitor: useIVisitResults.interrupt(boolean)to stop the process)voidUsed 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.
-
Field Details
-
skipAssignmentDestination
public boolean skipAssignmentDestination -
skipVisitingChildren
public boolean skipVisitingChildrenfor DFS pre-order only -
currentNode
for DFS pre-order only -
visitedChildPosition
public int visitedChildPositionInternal 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
optional queue used to record parents; non-null only ifIVisitResults.FLAG_RECORD_PARENTSwas used when creating the object
-
-
Constructor Details
-
AbstractVisitResults
public AbstractVisitResults() -
AbstractVisitResults
public AbstractVisitResults(int flags)
-
-
Method Details
-
getFlags
public int getFlags() -
pushParent
-
popParent
public void popParent() -
parentsIterator
Description copied from interface:IVisitResultsOptional iterator containing the parents; non-null only ifIVisitResults.FLAG_RECORD_PARENTSwas 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:
parentsIteratorin interfaceIVisitResults<T>
-
parent
Description copied from interface:IVisitResultsThis 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:
parentin interfaceIVisitResults<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:IVisitResultsNotify the visitor that the visit of the tree should be stopped.- Specified by:
interruptin interfaceIVisitResults<T>- Parameters:
success- the result of the visit
-
interrupt
public void interrupt(boolean success, int forcedValue) Description copied from interface:IVisitResultsNotify the visitor that the visit of the tree should be stopped.- Specified by:
interruptin interfaceIVisitResults<T>- Parameters:
success- visit resultforcedValue- optional return value, can be retrieved viaIVisitResults.getValue()
-
isInterruptedVisit
public boolean isInterruptedVisit()- Specified by:
isInterruptedVisitin interfaceIVisitResults<T>- Returns:
-
setVisitResult
public void setVisitResult(boolean success) Description copied from interface:IVisitResultsSaves the visit result (do not stop the visitor: useIVisitResults.interrupt(boolean)to stop the process)- Specified by:
setVisitResultin interfaceIVisitResults<T>
-
isVisitedSuccessfully
public boolean isVisitedSuccessfully()- Specified by:
isVisitedSuccessfullyin interfaceIVisitResults<T>- Returns:
-
getValue
public int getValue()- Specified by:
getValuein interfaceIVisitResults<T>- Returns:
-
setValue
public void setValue(int v) - Specified by:
setValuein interfaceIVisitResults<T>
-
skipChildren
public void skipChildren()Description copied from interface:IVisitResultsUsed 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:
skipChildrenin interfaceIVisitResults<T>
-
setReplacedNode
Description copied from interface:IVisitResultsNotify the visitor that the current node was replaced by theprocessmethod.Note: usage of this method is not mandatory in a DFS post-order traversal.
- Specified by:
setReplacedNodein interfaceIVisitResults<T>- Parameters:
newNode- the non-null new node
-