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_PARENTS
was used when creating the objectboolean
boolean
for DFS pre-order onlyint
Internal 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 TypeMethodDescriptionint
getFlags()
int
void
interrupt
(boolean success) Notify the visitor that the visit of the tree should be stopped.void
interrupt
(boolean success, int code) Notify the visitor that the visit of the tree should be stopped.boolean
boolean
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_PARENTS
was used when creating the object.void
void
pushParent
(T parent) void
setReplacedNode
(T newNode) Notify the visitor that the current node was replaced by theprocess
method.void
setVisitResult
(boolean success) Saves the visit result (do not stop the visitor: useIVisitResults.interrupt(boolean)
to stop the process)void
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.
-
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_PARENTS
was 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:IVisitResults
Optional iterator containing the parents; non-null only ifIVisitResults.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 interfaceIVisitResults<T>
-
parent
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 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:IVisitResults
Notify the visitor that the visit of the tree should be stopped.- Specified by:
interrupt
in interfaceIVisitResults<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 interfaceIVisitResults<T>
- Parameters:
success
- visit resultcode
- optional code, can be retrieved viaIVisitResults.getResultCode()
-
isInterruptedVisit
public boolean isInterruptedVisit()- Specified by:
isInterruptedVisit
in interfaceIVisitResults<T>
- Returns:
-
setVisitResult
public void setVisitResult(boolean success) Description copied from interface:IVisitResults
Saves the visit result (do not stop the visitor: useIVisitResults.interrupt(boolean)
to stop the process)- Specified by:
setVisitResult
in interfaceIVisitResults<T>
-
isVisitedSuccessfully
public boolean isVisitedSuccessfully()- Specified by:
isVisitedSuccessfully
in interfaceIVisitResults<T>
- Returns:
-
getResultCode
public int getResultCode()- Specified by:
getResultCode
in interfaceIVisitResults<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 interfaceIVisitResults<T>
-
setReplacedNode
Description copied from interface:IVisitResults
Notify the visitor that the current node was replaced by theprocess
method.Note: usage of this method is not mandatory in a DFS post-order traversal.
- Specified by:
setReplacedNode
in interfaceIVisitResults<T>
- Parameters:
newNode
- the non-null new node
-