org.teiid.language.visitor
Class CollectorVisitor<T>

java.lang.Object
  extended by org.teiid.language.visitor.AbstractLanguageVisitor
      extended by org.teiid.language.visitor.HierarchyVisitor
          extended by org.teiid.language.visitor.CollectorVisitor<T>
All Implemented Interfaces:
LanguageObjectVisitor

public class CollectorVisitor<T>
extends HierarchyVisitor

This visitor can be used to collect all objects of a certain type in a language tree. Each visit method does an instanceof method to check whether the object is of the expected type.


Constructor Summary
CollectorVisitor(java.lang.Class<T> type)
           
 
Method Summary
static java.util.Collection<ColumnReference> collectElements(LanguageObject object)
          This is a utility method for a common use of this visitor, which is to collect all elements in an object tree.
static java.util.Collection<NamedTable> collectGroups(LanguageObject object)
          This is a utility method for a common use of this visitor, which is to collect all groups in an object tree.
static java.util.Set<NamedTable> collectGroupsUsedByElements(LanguageObject object)
          This is a utility method for a common use of this visitor, which is to collect all groups used by all elements in an object tree.
static
<T> java.util.Collection<T>
collectObjects(java.lang.Class<T> type, LanguageObject object)
          This is a utility method to instantiate and run the visitor in conjunction with a HierarchyVisitor to collect all objects of the specified type of the specified tree in the language object tree.
 java.util.Collection<T> getCollectedObjects()
           
 void visitNode(LanguageObject obj)
          Visit the ILanguageObject instance to perform the Visitor's operation on that instance.
 
Methods inherited from class org.teiid.language.visitor.HierarchyVisitor
visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit
 
Methods inherited from class org.teiid.language.visitor.AbstractLanguageVisitor
visit, visit, visit, visit, visit, visit, visit, visitNodes, visitNodes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CollectorVisitor

public CollectorVisitor(java.lang.Class<T> type)
Method Detail

visitNode

public void visitNode(LanguageObject obj)
Description copied from class: AbstractLanguageVisitor
Visit the ILanguageObject instance to perform the Visitor's operation on that instance. This method can also be used by the subclass to visit any ILanguageObject instances that the given instance may contain.

Overrides:
visitNode in class AbstractLanguageVisitor
Parameters:
obj - an ILanguageObject instance
See Also:
HierarchyVisitor

getCollectedObjects

public java.util.Collection<T> getCollectedObjects()

collectObjects

public static <T> java.util.Collection<T> collectObjects(java.lang.Class<T> type,
                                                         LanguageObject object)
This is a utility method to instantiate and run the visitor in conjunction with a HierarchyVisitor to collect all objects of the specified type of the specified tree in the language object tree.

Parameters:
type - Language object type to look for
object - Root of the language object tree
Returns:
Collection of ILanguageObject of the specified type

collectElements

public static java.util.Collection<ColumnReference> collectElements(LanguageObject object)
This is a utility method for a common use of this visitor, which is to collect all elements in an object tree.

Parameters:
type - Language object type to look for
object - Root of the language object tree
Returns:
Collection of IElement of the specified type

collectGroups

public static java.util.Collection<NamedTable> collectGroups(LanguageObject object)
This is a utility method for a common use of this visitor, which is to collect all groups in an object tree.

Parameters:
type - Language object type to look for
object - Root of the language object tree
Returns:
Collection of IGroup of the specified type

collectGroupsUsedByElements

public static java.util.Set<NamedTable> collectGroupsUsedByElements(LanguageObject object)
This is a utility method for a common use of this visitor, which is to collect all groups used by all elements in an object tree.

Parameters:
type - Language object type to look for
object - Root of the language object tree
Returns:
Set of IGroup


Copyright © 2011. All Rights Reserved.