Interface IVisitResults<T>
- All Known Implementing Classes:
AbstractVisitResults,CVisitResults,DVisitResults,EVisitResults,JVisitResults
public interface IVisitResults<T>
Visit results interface for statement trees.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intRecord the parents in a stack, made available when visiting a child.static final intSkip written (defined) elements. -
Method Summary
Modifier and TypeMethodDescriptionintgetValue()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 ifFLAG_RECORD_PARENTSwas used when creating the object.voidsetReplacedNode(T newNode) Notify the visitor that the current node was replaced by theprocessmethod.voidsetValue(int value) voidsetVisitResult(boolean success) Saves the visit result (do not stop the visitor: useinterrupt(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
-
FLAG_RECORD_PARENTS
static final int FLAG_RECORD_PARENTSRecord the parents in a stack, made available when visiting a child. Parents recording is seldom used, and disabled by default.- See Also:
-
FLAG_SKIP_ASSIGN_DST
static final int FLAG_SKIP_ASSIGN_DSTSkip written (defined) elements. Note: the name of this flag is misleading, implementations may skip more than simply the destination of assignments.- See Also:
-
-
Method Details
-
interrupt
void interrupt(boolean success) Notify the visitor that the visit of the tree should be stopped.- Parameters:
success- the result of the visit
-
interrupt
void interrupt(boolean success, int forcedValue) Notify the visitor that the visit of the tree should be stopped.- Parameters:
success- visit resultforcedValue- optional return value, can be retrieved viagetValue()
-
setVisitResult
void setVisitResult(boolean success) Saves the visit result (do not stop the visitor: useinterrupt(boolean)to stop the process)- Parameters:
success-
-
isInterruptedVisit
boolean isInterruptedVisit()- Returns:
-
isVisitedSuccessfully
boolean isVisitedSuccessfully()- Returns:
-
getValue
int getValue()- Returns:
-
setValue
void setValue(int value) - Parameters:
value-
-
skipChildren
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.
-
setReplacedNode
Notify the visitor that the current node was replaced by theprocessmethod.Note: usage of this method is not mandatory in a DFS post-order traversal.
- Parameters:
newNode- the non-null new node
-
parentsIterator
Optional iterator containing the parents; non-null only ifFLAG_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. -
parent
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
-