com.interface21.core
Interface Visitor

All Known Implementing Classes:
PrettyPrintVisitor, NodeCountVisitor

public interface Visitor

Interface to be implemented by Objects implementing the Visitor design pattern.
Implementing objects will have to understand the structure of objects they visit: e.g. to convert their structure into XML output.

Since:
15.10.1999
Author:
Rod Johnson
See Also:
Visitable

Method Summary
 boolean enterComposite(Visitable host, int depth)
          Begin a visit to a composite element, with subnodes.
 void exitComposite(Visitable host)
          End a visit to a composite element, with subnodes
 void visitLeaf(Visitable host, int depth)
          Make an entire visit to a terminal node
 

Method Detail

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.
Parameters:
host - Node accepting the Visitor
depth - 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
Parameters:
host - node visited

visitLeaf

public void visitLeaf(Visitable host,
                      int depth)
Make an entire visit to a terminal node
Parameters:
host - node to be visited
depth - depth of traversal (starting at 0)


Rod Johnson and Spring contributors 2001-2003.