Class Function

  • All Implemented Interfaces:
    Cloneable, LanguageObject, Expression, NamedExpression
    Direct Known Subclasses:
    AggregateSymbol

    public class Function
    extends Object
    implements NamedExpression
    Represents a function in a sql statement. A function is a type of expression. Functions have a name and some arguments (0..n). Each argument is also an expression. After resolution, a function should have a type and a function descriptor.
    • Field Detail

      • type

        protected Class<?> type
    • Constructor Detail

      • Function

        public Function​(String name,
                        Expression[] args)
        Construct a function with function name and array of arguments. For functions that have no args, pass empty array, not null.
        Parameters:
        name - Name of function
        args - Function arguments
    • Method Detail

      • setName

        public void setName​(String name)
      • getArgs

        public Expression[] getArgs()
        Get function arguments
        Returns:
        Get function arguments
      • getArg

        public Expression getArg​(int index)
        Get argument at specified index
        Parameters:
        index - Index of argument
      • setArgs

        public void setArgs​(Expression[] args)
        Set the function arguments - it is assumed that the args are not null. For no arg functions, use an empty Expression array.
        Parameters:
        args - Function arguments
      • makeImplicit

        public void makeImplicit()
        Make this function implicit / hidden.
      • isImplicit

        public boolean isImplicit()
        Return true if this function is implicit and should not be shown in SQL representations
        Returns:
        True if implicit
      • setImplicit

        public void setImplicit​(boolean implicit)
      • insertConversion

        public void insertConversion​(int index,
                                     FunctionDescriptor functionDescriptor)
        Insert a conversion function at specified index. This is a convenience method to insert a conversion into the function tree.
        Parameters:
        index - Argument index to insert conversion function at
        functionDescriptor - Conversion function descriptor
      • getType

        public Class<?> getType()
        Get type of function, if known
        Specified by:
        getType in interface Expression
        Returns:
        Java class name of type, or null if not yet resolved
      • setType

        public void setType​(Class<?> type)
        Set type of function
        Parameters:
        type - New type
      • getFunctionDescriptor

        public FunctionDescriptor getFunctionDescriptor()
        Get the function descriptor that this function resolves to.
        Returns:
        Descriptor or null if resolution has not yet occurred
      • setFunctionDescriptor

        public void setFunctionDescriptor​(FunctionDescriptor fd)
        Set the descriptor for this function.
        Parameters:
        fd - Function descriptor
      • acceptVisitor

        public void acceptVisitor​(LanguageVisitor visitor)
        Description copied from interface: LanguageObject
        Method for accepting a visitor. It is the responsibility of the language object to call back on the visitor.
        Specified by:
        acceptVisitor in interface LanguageObject
        Parameters:
        visitor - Visitor being used
      • equals

        public boolean equals​(Object obj)
        Compare for equality
        Overrides:
        equals in class Object
        Parameters:
        obj - Other object to compare
        Returns:
        Return true if objects are equivalent
      • hashCode

        public int hashCode()
        Compute hash code for the object - based on name and hashcode of first arg (if there is one)
        Overrides:
        hashCode in class Object
        Returns:
        Hash code
      • clone

        public Object clone()
        Return a deep copy of this object.
        Specified by:
        clone in interface LanguageObject
        Overrides:
        clone in class Object
        Returns:
        Deep copy of the object
      • isAggregate

        public boolean isAggregate()
      • toString

        public String toString()
        Return string representation of the function.
        Overrides:
        toString in class Object
        Returns:
        String representation
      • isEval

        public boolean isEval()
      • setEval

        public void setEval​(boolean eval)
      • isCalledWithVarArgArrayParam

        public boolean isCalledWithVarArgArrayParam()
      • setCalledWithVarArgArrayParam

        public void setCalledWithVarArgArrayParam​(boolean calledWithVarArgArrayParam)
      • setPushdownFunction

        public void setPushdownFunction​(FunctionMethod pushdownFunction)