|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectxtc.tree.Visitor
public abstract class Visitor
The superclass of all node visitors.
Nodes may contain children that are lists of nodes. To simplify the processing of such lists with visitors, this class defines three helper methods that apply a visitor to a list of nodes:iterate(Pair) invokes dispatch() on each
element of the list and ignores any results.map(Pair) invokes dispatch() on each
element of the list while also collecting the results in a new
list.mapInPlace(Pair) invokes dispatch() on
each element of the list while also updating the list with the
results.Node provides helper methods to
dynamically test and cast lists of nodes through Node.isList(Object) and Node.toList(Object) respectively.
| Constructor Summary | |
|---|---|
Visitor()
Create a new visitor. |
|
| Method Summary | ||
|---|---|---|
java.lang.Object |
dispatch(Node n)
Dispatch this visitor on the specified node. |
|
boolean |
equals(java.lang.Object o)
Determine whether this visitor equals the specified object. |
|
int |
hashCode()
Get a hashcode for this visitor. |
|
void |
iterate(Pair<? extends Node> list)
Iterate this visitor over the specified list. |
|
|
map(Pair<? extends Node> list)
Map this visitor over the specified list. |
|
|
mapInPlace(Pair<T> list)
Map this visitor over the specified list while also updating the list. |
|
java.lang.Object |
unableToVisit(Node node)
Signal that this visitor has no visit() method for
the specified node. |
|
java.lang.Object |
visit(Annotation a)
Visit the specified annotation. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Visitor()
| Method Detail |
|---|
public final int hashCode()
hashCode in class java.lang.Objectpublic final boolean equals(java.lang.Object o)
equals in class java.lang.Objecto - The object to compare to.
true if the specified object is this visitor.public java.lang.Object visit(Annotation a)
a - The annotation.
public final java.lang.Object dispatch(Node n)
visit() method,
invokes it on the specified node, and returns the result. If the
specified node is null or the selected method
returns void, this method returns null.
n - The node.
VisitorException - Signals that no matching
visit() method could be found.
VisitingException - Signals an exceptional condition while
applying the specified visitor on this node.unableToVisit(Node)public java.lang.Object unableToVisit(Node node)
visit() method for
the specified node. The default implementation simply raises a
visitor exception.
node - The node.
VisitorException - Signals that no matching
visit() method could be found.public void iterate(Pair<? extends Node> list)
list - The list.public <T> Pair<T> map(Pair<? extends Node> list)
list - The list.
public <T extends Node> Pair<T> mapInPlace(Pair<T> list)
list - The list.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||