public class CompositeElementVisitor extends java.lang.Object implements ElementVisitor
ElementVisitor.StoppedException
Constructor and Description |
---|
CompositeElementVisitor(ElementVisitor... visitors)
Constructs a new CompositeElementVisitor instance containing the array of
visitor instances passed in.
|
Modifier and Type | Method and Description |
---|---|
void |
addVisitor(ElementVisitor visitor)
Adds a new
ElementVisitor instance to the composite visitor. |
ElementVisitor.StoppedException |
getStoppedException(ElementVisitor visitor)
Returns any StoppedException thrown by the specified visitor, or
null if the visitor completed normally. |
java.util.List<ElementVisitor> |
getVisitors()
Returns the list of active element visitor instances.
|
boolean |
visit(Element parent,
Element target,
ElementMetadata<?,?> metadata)
Called during Element tree traversal to allow the visitor instance
to process an element in the tree.
|
void |
visitComplete(Element parent,
Element target,
ElementMetadata<?,?> metadata)
The visitComplete method is called when traversal for an Element
and all of its nested children has been completed.
|
public CompositeElementVisitor(ElementVisitor... visitors)
visitors
- list of ElementVisitor instances to compose.public void addVisitor(ElementVisitor visitor)
ElementVisitor
instance to the composite visitor. For
any element, events will be delivered to the added visitor after events
have been delivered to other visitors already contained in the composite
visitor at the time of addition.visitor
- the new visitor to add.public java.util.List<ElementVisitor> getVisitors()
public ElementVisitor.StoppedException getStoppedException(ElementVisitor visitor)
null
if the visitor completed normally.public boolean visit(Element parent, Element target, ElementMetadata<?,?> metadata) throws ElementVisitor.StoppedException
ElementVisitor
visit
in interface ElementVisitor
parent
- the parent of the target elementtarget
- the target element being visitedmetadata
- the metadata for the target elementElementVisitor.StoppedException
- if the data model traversal should be stopped
immediately. This may be the result of an unexpected error, or some
visitor implementations may extend this exception type to signal
specific exit conditions.public void visitComplete(Element parent, Element target, ElementMetadata<?,?> metadata) throws ElementVisitor.StoppedException
ElementVisitor
visitComplete
in interface ElementVisitor
parent
- the parent of the target elementtarget
- the visited elementmetadata
- the metadata for the target elementElementVisitor.StoppedException
- if the data model traversal should be stopped
immediately. This may be the result of an unexpected error, or some
visitor implementations may extend this exception type to signal
specific exit conditions.