public class

CompositeElementVisitor

extends Object
implements ElementVisitor
java.lang.Object
   ↳ com.google.gdata.model.CompositeElementVisitor

Class Overview

This class provides an ElementVisitor implementation that aggregates multiple nested ElementVisitor instances. This makes it possible to apply several different unrelated visitor implementations during a single data model tree traversal.

Summary

Fields
private final Map<ElementVisitorElement> ignoringVisitors The ignoringVisitors map contains information about visitors that are currently ignoring child events.
private final Map<ElementVisitorElementVisitor.StoppedException> stoppedVisitors Contains the collection of inactive ElementVisitor instance and the ElementVisitor.StoppedException that made them inactive.
private final List<ElementVisitor> visitors The visitors field contains a list of the active ElementVisitor instances for the composite visitor.
Public Constructors
CompositeElementVisitor(ElementVisitor... visitors)
Constructs a new CompositeElementVisitor instance containing the array of visitor instances passed in.
Public Methods
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.
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.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.gdata.model.ElementVisitor

Fields

private final Map<ElementVisitorElement> ignoringVisitors

The ignoringVisitors map contains information about visitors that are currently ignoring child events. The key will be the visitor instance that is ignoring child events and the value will be the element beneath which all child events are being ignored.

private final Map<ElementVisitorElementVisitor.StoppedException> stoppedVisitors

Contains the collection of inactive ElementVisitor instance and the ElementVisitor.StoppedException that made them inactive.

private final List<ElementVisitor> visitors

The visitors field contains a list of the active ElementVisitor instances for the composite visitor.

Public Constructors

public CompositeElementVisitor (ElementVisitor... visitors)

Constructs a new CompositeElementVisitor instance containing the array of visitor instances passed in. The order in which each visitor instance appears in the array is significant; it defines the order in which events for a given element will be delivered to the nested instances.

Parameters
visitors List of ElementVisitor instances to compose.

Public Methods

public void addVisitor (ElementVisitor visitor)

Adds a new 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.

Parameters
visitor The new visitor to add.

public ElementVisitor.StoppedException getStoppedException (ElementVisitor visitor)

Returns any StoppedException thrown by the specified visitor, or null if the visitor completed normally.

Parameters
visitor

public List<ElementVisitor> getVisitors ()

Returns the list of active element visitor instances. Any stopped visitors will not appear in this list.

Returns
  • list of visitor instances in order of event delivery.

public 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.

Parameters
parent The parent of the target element
target The target element being visited
metadata The metadata for the target element
Returns
  • boolean value indicating whether child elements (if any) should be visited.

public 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.

Parameters
parent The parent of the target element
target The visited element
metadata The metadata for the target element