Class 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 Detail

      • CollectorVisitor

        public CollectorVisitor​(Class<T> type)
    • Method Detail

      • visitNode

        public void visitNode​(LanguageObject obj)
        Description copied from class: AbstractLanguageVisitor
        Visit the LanguageObject instance to perform the Visitor's operation on that instance. This method can also be used by the subclass to visit any LanguageObject instances that the given instance may contain.
        Overrides:
        visitNode in class AbstractLanguageVisitor
        Parameters:
        obj - an LanguageObject instance
        See Also:
        HierarchyVisitor
      • getCollectedObjects

        public Collection<T> getCollectedObjects()
      • collectObjects

        public static <T> Collection<T> collectObjects​(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 LanguageObject of the specified type
      • collectElements

        public static 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:
        object - Root of the language object tree
        Returns:
        Collection of IElement of the specified type
      • collectGroups

        public static 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:
        object - Root of the language object tree
        Returns:
        Collection of IGroup of the specified type
      • collectGroupsUsedByElements

        public static 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:
        object - Root of the language object tree
        Returns:
        Set of IGroup