Package org.teiid.query.sql.symbol
Class Function
- java.lang.Object
-
- org.teiid.query.sql.symbol.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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.teiid.query.sql.LanguageObject
LanguageObject.Util
-
-
Constructor Summary
Constructors Constructor Description Function(String name, Expression[] args)
Construct a function with function name and array of arguments.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acceptVisitor(LanguageVisitor visitor)
Method for accepting a visitor.Object
clone()
Return a deep copy of this object.boolean
equals(Object obj)
Compare for equalityExpression
getArg(int index)
Get argument at specified indexExpression[]
getArgs()
Get function argumentsFunctionDescriptor
getFunctionDescriptor()
Get the function descriptor that this function resolves to.String
getName()
Get name of functionFunctionMethod
getPushdownFunction()
Class<?>
getType()
Get type of function, if knownint
hashCode()
Compute hash code for the object - based on name and hashcode of first arg (if there is one)void
insertConversion(int index, FunctionDescriptor functionDescriptor)
Insert a conversion function at specified index.boolean
isAggregate()
boolean
isCalledWithVarArgArrayParam()
boolean
isEval()
boolean
isImplicit()
Return true if this function is implicit and should not be shown in SQL representationsvoid
makeImplicit()
Make this function implicit / hidden.void
setArgs(Expression[] args)
Set the function arguments - it is assumed that the args are not null.void
setCalledWithVarArgArrayParam(boolean calledWithVarArgArrayParam)
void
setEval(boolean eval)
void
setFunctionDescriptor(FunctionDescriptor fd)
Set the descriptor for this function.void
setImplicit(boolean implicit)
void
setName(String name)
void
setPushdownFunction(FunctionMethod pushdownFunction)
void
setType(Class<?> type)
Set type of functionString
toString()
Return string representation of the function.
-
-
-
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 functionargs
- Function arguments
-
-
Method Detail
-
getName
public String getName()
Get name of function- Specified by:
getName
in interfaceNamedExpression
- Returns:
- Name of function
-
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 atfunctionDescriptor
- Conversion function descriptor
-
getType
public Class<?> getType()
Get type of function, if known- Specified by:
getType
in interfaceExpression
- 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 interfaceLanguageObject
- Parameters:
visitor
- Visitor being used
-
equals
public boolean equals(Object obj)
Compare for equality
-
hashCode
public int hashCode()
Compute hash code for the object - based on name and hashcode of first arg (if there is one)
-
clone
public Object clone()
Return a deep copy of this object.- Specified by:
clone
in interfaceLanguageObject
- Overrides:
clone
in classObject
- Returns:
- Deep copy of the object
-
isAggregate
public boolean isAggregate()
-
toString
public String toString()
Return string representation of the function.
-
isEval
public boolean isEval()
-
setEval
public void setEval(boolean eval)
-
isCalledWithVarArgArrayParam
public boolean isCalledWithVarArgArrayParam()
-
setCalledWithVarArgArrayParam
public void setCalledWithVarArgArrayParam(boolean calledWithVarArgArrayParam)
-
getPushdownFunction
public FunctionMethod getPushdownFunction()
-
setPushdownFunction
public void setPushdownFunction(FunctionMethod pushdownFunction)
-
-