public interface Visitable
The Visitor design pattern represents operations to be performed on the elements of an object structure. The pattern encapsulates operations into methods separate from the structure, which only needs to accept the visitor and allow it to access its state, generally by passing back a reference to itself to an overloaded method tailored to the class of the visited instance.abstract class for Visitors.
|Modifier and Type||Method and Description|
Accepts a ComponentVisitor that traverses a document structure tree.
Accepts a ComponentVisitor that traverses a document structure tree in preorder or postorder.
void accept(ComponentVisitor visitor)
When called from an object that implements the
accept( visitor )on all its children
The reference is passed back to the visitor through a method of the form
visitor.visit<ComponentClassName>( this );
The order of steps 1 and 2 determines if traversal of the composite structure is preorder or postorder. As shown above, it's preorder. Depending on what you want to do, one traversal may be better suited than the other. Preorder visits parents first, postorder visits children first.
void accept(ComponentVisitor visitor, boolean order)
order- boolean to determine if traversal is preorder or postorder
accept( visitor )should implement the default order of traversal,
accept( visitor, <false>) should implement the other order.
Processing library IgnoCodeLib by Paul Hertz. (c) 2015