|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Visitable
Interface for display components that implement the Visitor design pattern.
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.
Method Summary | |
---|---|
void |
accept(ComponentVisitor visitor)
Accepts a ComponentVisitor that traverses a document structure tree. |
void |
accept(ComponentVisitor visitor,
boolean order)
Accepts a ComponentVisitor that traverses a document structure tree in preorder or postorder. |
Method Detail |
---|
void accept(ComponentVisitor visitor)
When called from an object that implements the Visitable
interface:
accept( visitor )
on all its children
The reference is passed back to the visitor through a method of the form
visitor.visit<ComponentClassName>( this );
See ComponentVisitor
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.
visitor
- a ComponentVisitor
void accept(ComponentVisitor visitor, boolean order)
visitor
- a ComponentVisitor
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.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |