|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.sri.oaa2.icl.IclTermTraverser
An abstract class for doing depth first traversal of an IclTerm. This is an alternative to the Visitor pattern that exists in the IclTerm class. To use it, just create a subclass and provide the discover(IclTerm) and finish(IclTerm) methods. The discover method is called when an IclTerm is first encountered, and the finish method is called when all the children of an IclTerm have been finished. Given an IclTerm t, if t.isAtomic() is true, then finish() will be called immediately after discover() has been called.
Implementation wise, this is faster than a standard recursive traversal, since existing implementations of Java don't handle recursion well.
For an example of using this class, look at the source for GenerateManualConstruction. ToString does something similar, but much more specialized.
| Constructor Summary | |
IclTermTraverser()
|
|
| Method Summary | |
abstract boolean |
discover(IclTerm t)
Called when an IclTerm is first visited. |
abstract boolean |
finish(IclTerm t)
Called when an IclTerm's children have all been visited. |
void |
traverse(IclTerm t)
Perform a traversal on the given IclTerm. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public IclTermTraverser()
| Method Detail |
public abstract boolean discover(IclTerm t)
t - The IclTerm that was discovered.
public abstract boolean finish(IclTerm t)
t - The IclTerm that was finished.
public final void traverse(IclTerm t)
t - The IclTerm to traverse.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||