Class AbstractVisitResults<T>
java.lang.Object
com.pnfsoftware.jeb.core.units.code.AbstractVisitResults<T>
- Type Parameters:
T- visited node type
- 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 objectbooleanTrue to skip assignment destinations.booleanfor 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
ConstructorsConstructorDescriptionCreate visit results with default flags.AbstractVisitResults(int flags) Create visit results. -
Method Summary
Modifier and TypeMethodDescriptionintgetFlags()Get visit flags.intgetValue()Get the visit value.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.booleanDetermine whether the visit was interrupted.booleanDetermine whether the visit completed successfully.parent(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.voidPop the current parent node.voidpushParent(T parent) Push a parent node.voidsetReplacedNode(T newNode) Notify the visitor that the current node was replaced by theprocessmethod.voidsetValue(int v) Set the visit value.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 skipAssignmentDestinationTrue to skip assignment destinations. -
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()Create visit results with default flags. -
AbstractVisitResults
public AbstractVisitResults(int flags) Create visit results.- Parameters:
flags- visit flags
-
-
Method Details
-
getFlags
public int getFlags()Get visit flags.- Returns:
- visit flags
-
pushParent
Push a parent node.- Parameters:
parent- parent node
-
popParent
public void popParent()Pop the current parent node. -
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>- Returns:
- parent iterator
-
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()Description copied from interface:IVisitResultsDetermine whether the visit was interrupted.- Specified by:
isInterruptedVisitin interfaceIVisitResults<T>- Returns:
- true if the visit was interrupted
-
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>- Parameters:
success- visit result
-
isVisitedSuccessfully
public boolean isVisitedSuccessfully()Description copied from interface:IVisitResultsDetermine whether the visit completed successfully.- Specified by:
isVisitedSuccessfullyin interfaceIVisitResults<T>- Returns:
- true if the visit was successful
-
getValue
public int getValue()Description copied from interface:IVisitResultsGet the visit value.- Specified by:
getValuein interfaceIVisitResults<T>- Returns:
- visit value
-
setValue
public void setValue(int v) Description copied from interface:IVisitResultsSet the visit value.- Specified by:
setValuein interfaceIVisitResults<T>- Parameters:
v- visit value
-
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
-