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 int
Record the parents in a stack, made available when visiting a child.static final int
Skip written (defined) elements. -
Method Summary
Modifier and TypeMethodDescriptionint
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 ifFLAG_RECORD_PARENTS
was used when creating the object.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: useinterrupt(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
-
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 code) Notify the visitor that the visit of the tree should be stopped.- Parameters:
success
- visit resultcode
- optional code, can be retrieved viagetResultCode()
-
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:
-
getResultCode
int getResultCode()- Returns:
-
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 theprocess
method.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_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. -
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
-