Package com.mckoi.database
Class AbstractFunction
- java.lang.Object
-
- com.mckoi.database.AbstractFunction
-
- All Implemented Interfaces:
Function
- Direct Known Subclasses:
AbstractAggregateFunction,InternalFunctionFactory.AbsFunction,InternalFunctionFactory.BinaryToHexFunction,InternalFunctionFactory.CoalesceFunction,InternalFunctionFactory.ConcatFunction,InternalFunctionFactory.CountFunction,InternalFunctionFactory.CurrValFunction,InternalFunctionFactory.DateFormatFunction,InternalFunctionFactory.DateObFunction,InternalFunctionFactory.DistinctCountFunction,InternalFunctionFactory.ForeignRuleConvert,InternalFunctionFactory.GreatestFunction,InternalFunctionFactory.HexToBinaryFunction,InternalFunctionFactory.IfFunction,InternalFunctionFactory.JavaObjectInstantiation,InternalFunctionFactory.JavaObjectInstantiation2,InternalFunctionFactory.LeastFunction,InternalFunctionFactory.LengthFunction,InternalFunctionFactory.LowerFunction,InternalFunctionFactory.LTrimFunction,InternalFunctionFactory.ModFunction,InternalFunctionFactory.NextValFunction,InternalFunctionFactory.PowFunction,InternalFunctionFactory.PrivGroupsFunction,InternalFunctionFactory.PrivilegeString,InternalFunctionFactory.RoundFunction,InternalFunctionFactory.RTrimFunction,InternalFunctionFactory.SetValFunction,InternalFunctionFactory.SignFunction,InternalFunctionFactory.SQLCastFunction,InternalFunctionFactory.SQLTrimFunction,InternalFunctionFactory.SQLTypeString,InternalFunctionFactory.SqrtFunction,InternalFunctionFactory.SubstringFunction,InternalFunctionFactory.TimeObFunction,InternalFunctionFactory.TimeStampObFunction,InternalFunctionFactory.ToNumberFunction,InternalFunctionFactory.UniqueKeyFunction,InternalFunctionFactory.UpperFunction,InternalFunctionFactory.UserFunction,InternalFunctionFactory.ViewDataConvert
public abstract class AbstractFunction extends java.lang.Object implements Function
An abstract implementation of Function.
-
-
Field Summary
Fields Modifier and Type Field Description private booleanis_aggregateSet to true if this is an aggregate function (requires a group).private java.lang.StringnameThe name of the function.private Expression[]paramsThe list of expressions this function has as parameters.
-
Constructor Summary
Constructors Constructor Description AbstractFunction(java.lang.String name, Expression[] params)Constructs the Function with the given expression array as parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.ListallElements()Returns the list of all elements that are used by this function.java.util.ListallVariables()Returns the list of all Variable's that are used by this function.java.lang.StringgetName()Returns the name of the function.ExpressiongetParameter(int n)Returns the parameter at the given index in the parameters list.voidinit(VariableResolver resolver)The init function.booleanisAggregate(QueryContext context)Returns whether the function is an aggregate function or not.booleanisGlob()Returns true if the param is the special case glob parameter (*).intparameterCount()Returns the number of parameters for this function.voidprepareParameters(ExpressionPreparer preparer)Prepares the parameters of the function.TTypereturnTType()TTypereturnTType(VariableResolver resolver, QueryContext context)By Default, we assume a function returns a Numeric object.protected voidsetAggregate(boolean status)Call this from the constructor if the function is an aggregate.java.lang.StringtoString()
-
-
-
Field Detail
-
name
private java.lang.String name
The name of the function.
-
params
private Expression[] params
The list of expressions this function has as parameters.
-
is_aggregate
private boolean is_aggregate
Set to true if this is an aggregate function (requires a group). It is false by default.
-
-
Constructor Detail
-
AbstractFunction
public AbstractFunction(java.lang.String name, Expression[] params)Constructs the Function with the given expression array as parameters.
-
-
Method Detail
-
setAggregate
protected void setAggregate(boolean status)
Call this from the constructor if the function is an aggregate.
-
parameterCount
public int parameterCount()
Returns the number of parameters for this function.
-
getParameter
public Expression getParameter(int n)
Returns the parameter at the given index in the parameters list.
-
isGlob
public boolean isGlob()
Returns true if the param is the special case glob parameter (*).
-
getName
public java.lang.String getName()
Returns the name of the function. The name is a unique identifier that can be used to recreate this function. This identifier can be used to easily serialize the function when grouped with its parameters.
-
allVariables
public java.util.List allVariables()
Returns the list of all Variable's that are used by this function. This looks up each expression in the list of parameters. This will cascade if the expressions have a Function, etc.- Specified by:
allVariablesin interfaceFunction
-
allElements
public java.util.List allElements()
Returns the list of all elements that are used by this function. This looks up each expression in the list of parameters. This will cascade if the expressions have a Function, etc.- Specified by:
allElementsin interfaceFunction
-
isAggregate
public final boolean isAggregate(QueryContext context)
Returns whether the function is an aggregate function or not.- Specified by:
isAggregatein interfaceFunction
-
prepareParameters
public void prepareParameters(ExpressionPreparer preparer) throws DatabaseException
Prepares the parameters of the function.- Specified by:
prepareParametersin interfaceFunction- Throws:
DatabaseException
-
init
public void init(VariableResolver resolver)
The init function. By default, we don't do anything however this should be overwritten if we need to check the parameter arguments.
-
returnTType
public TType returnTType(VariableResolver resolver, QueryContext context)
By Default, we assume a function returns a Numeric object.- Specified by:
returnTTypein interfaceFunction
-
returnTType
public TType returnTType()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-