com.interface21.core
Class PrettyPrintVisitor
java.lang.Object
|
+--com.interface21.core.PrettyPrintVisitor
- All Implemented Interfaces:
- Visitor
- public class PrettyPrintVisitor
- extends java.lang.Object
- implements Visitor
Test visitor. Useful during development.
Produces console output as it visits each node
that shows the tree's structure.
- Version:
- 1.0
- Author:
- Rod Johnson
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PrettyPrintVisitor
public PrettyPrintVisitor()
- Creates new PrettyPrintVisitor
visitLeaf
public void visitLeaf(Visitable host,
int depth)
- Make an entire visit to a terminal node
- Specified by:
visitLeaf in interface Visitor
- Parameters:
host - node to be visiteddepth - depth of traversal (starting at 0)
enterComposite
public boolean enterComposite(Visitable host,
int depth)
- Begin a visit to a composite element, with subnodes.
Return false to just treat it as a terminal.
Note that either this method or exitComposite(), depending
on implementation, must do the actual visit to the composite,
as visit() will never be called on this node unless this
method returns false.
- Specified by:
enterComposite in interface Visitor
- Parameters:
host - Node accepting the Visitordepth - current depth in traversal, starting at 0.- Returns:
- true to treat this as a composite, and traverse
any children; false to treat it as a terminal, ignoring
any children.
exitComposite
public void exitComposite(Visitable host)
- End a visit to a composite element, with subnodes
- Specified by:
exitComposite in interface Visitor
- Parameters:
host - node visited
Rod Johnson and Spring contributors 2001-2003.