Class FunctionCollectorVisitor


  • public class FunctionCollectorVisitor
    extends LanguageVisitor

    This visitor class will traverse a language object tree and collect all Function references it finds. It uses a collection to collect the Functions in so different collections will give you different collection properties - for instance, using a Set will remove duplicates.

    This visitor can optionally collect functions of only a specific name

    The easiest way to use this visitor is to call the static methods which create the visitor (and possibly the collection), run the visitor, and return the collection. The public visit() methods should NOT be called directly.

    • Constructor Detail

      • FunctionCollectorVisitor

        public FunctionCollectorVisitor​(Collection<Function> functions)
        Construct a new visitor with the specified collection, which should be non-null.
        Parameters:
        functions - Collection to use for functions
        Throws:
        IllegalArgumentException - If elements is null
      • FunctionCollectorVisitor

        public FunctionCollectorVisitor​(Collection<Function> functions,
                                        String functionName)
        Construct a new visitor with the specified collection, which should be non-null.
        Parameters:
        functions - Collection to use for functions
        Throws:
        IllegalArgumentException - If elements is null
    • Method Detail

      • getFunctions

        public Collection<Function> getFunctions()
        Get the elements collected by the visitor. This should best be called after the visitor has been run on the language object tree.
        Returns:
        Collection of ElementSymbol
      • visit

        public void visit​(Function obj)
        Visit a language object and collect symbols. This method should NOT be called directly.
        Overrides:
        visit in class LanguageVisitor
        Parameters:
        obj - Language object
      • getFunctions

        public static final void getFunctions​(LanguageObject obj,
                                              Collection<Function> functions)
        Helper to quickly get the elements from obj in the elements collection
        Parameters:
        obj - Language object
        functions - Collection to collect functions in
      • getFunctions

        public static final void getFunctions​(LanguageObject obj,
                                              Collection<Function> functions,
                                              boolean deep)
        Helper to quickly get the elements from obj in the elements collection
        Parameters:
        obj - Language object
        functions - Collection to collect functions in
      • getFunctions

        public static final Collection<Function> getFunctions​(LanguageObject obj,
                                                              boolean removeDuplicates)
        Helper to quickly get the elements from obj in a collection. The removeDuplicates flag affects whether duplicate elements will be filtered out.
        Parameters:
        obj - Language object
        removeDuplicates - True to remove duplicates
        Returns:
        Collection of ElementSymbol
      • isNonDeterministic

        public static boolean isNonDeterministic​(LanguageObject ex)
        Checks to see if the object is non-deterministic iff all function are non-deterministic, and all correlated subqueries are deterministic
        Parameters:
        ex -
        Returns: