com.interface21.core
Interface Visitable
- public interface Visitable
Interface to be implemented by objects supporting the Visitor
design pattern.
- Since:
- 15.10.1999
- Author:
- Rod Johnson
acceptVisitor
public void acceptVisitor(Visitor v,
int depth)
- Accept the given visitor.
There are two cases:
- The host (this Visitable object) is a composite element,
with subnodes: The host is responsible for
calling the visitor's enterComposite() method,
calling the acceptVisitor(Visitor) method on any subnodes
implementing this interface, and calling the visitor's
exitComposite() method to end the visit. Note that the Visitor
can prevent the evaluation of subnodes by returning false
in enterComposite(), in which case this object should call
acceptVisitor() on itself instead of child nodes, and ignore
the call to exitComposite().
- The element is a leaf, with no subnodes:
The element must call the Visitor's visit() method on itself
- Parameters:
v - Visitordepth - current depth of traversal, starting at 0
Rod Johnson and Spring contributors 2001-2003.