Package adql.query.operand.function
Class DefaultUDF
java.lang.Object
adql.query.operand.function.ADQLFunction
adql.query.operand.function.UserDefinedFunction
adql.query.operand.function.DefaultUDF
- All Implemented Interfaces:
ADQLObject,ADQLOperand,UnknownType
It represents any function which is not managed by ADQL.
- Version:
- 2.0 (08/2020)
- Author:
- Grégory Mantelet (CDS;ARI)
-
Nested Class Summary
Nested classes/interfaces inherited from class adql.query.operand.function.ADQLFunction
ADQLFunction.ParameterIterator -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected FunctionDefDefine/Describe this user defined function.protected final StringParsed name of this UDF.protected final ADQLList<ADQLOperand>Its parsed parameters. -
Constructor Summary
ConstructorsConstructorDescriptionDefaultUDF(DefaultUDF toCopy) Builds a UserFunction by copying the given one.DefaultUDF(String name, ADQLOperand[] params) Creates a user function. -
Method Summary
Modifier and TypeMethodDescriptiongetCopy()Gets a (deep) copy of this ADQL object.final FunctionDefGet the signature/definition/description of this user defined function.final StringgetName()Gets the name of this object in ADQL.final intGets the number of parameters this function has.final ADQLOperandgetParameter(int index) Gets the index-th parameter.final ADQLOperand[]Gets the list of all parameters of this function.final booleanTell whether this operand is a geometrical region or not.final booleanTell whether this operand is numeric or not.final booleanisString()Tell whether this operand is a string or not.final voidsetDefinition(FunctionDef def) Let set the signature/definition/description of this user defined function.setParameter(int index, ADQLOperand replacer) Function to override if you want to check the parameters of this user defined function.translate(ADQLTranslator caller) Translate this User Defined Function into the language supported by the given translator.Methods inherited from class adql.query.operand.function.UserDefinedFunction
getExpectedType, setExpectedTypeMethods inherited from class adql.query.operand.function.ADQLFunction
adqlIterator, getPosition, paramIterator, setPosition, toADQLMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface adql.query.ADQLObject
adqlIterator, getPosition, toADQL
-
Field Details
-
definition
Define/Describe this user defined function. This object gives the return type and the number and type of all parameters. -
parameters
Its parsed parameters. -
functionName
Parsed name of this UDF.
-
-
Constructor Details
-
DefaultUDF
Creates a user function.- Parameters:
params- Parameters of the function.- Throws:
NullPointerException
-
DefaultUDF
Builds a UserFunction by copying the given one.- Parameters:
toCopy- The UserFunction to copy.- Throws:
Exception- If there is an error during the copy.
-
-
Method Details
-
getDefinition
Get the signature/definition/description of this user defined function. The returned object provides information on the return type and the number and type of parameters.- Returns:
- Definition of this function. (MAY be NULL)
-
setDefinition
Let set the signature/definition/description of this user defined function.IMPORTANT: No particular checks are done here except on the function name which MUST be the same (case insensitive) as the name of the given definition. Advanced checks must have been done before calling this setter.
- Parameters:
def- The definition applying to this parsed UDF, or NULL if none has been found.- Throws:
IllegalArgumentException- If the name in the given definition does not match the name of this parsed function.- Since:
- 1.3
-
isNumeric
public final boolean isNumeric()Description copied from interface:ADQLOperandTell whether this operand is numeric or not.- Returns:
- true if this operand is numeric, false otherwise.
-
isString
public final boolean isString()Description copied from interface:ADQLOperandTell whether this operand is a string or not.- Returns:
- true if this operand is a string, false otherwise.
-
isGeometry
public final boolean isGeometry()Description copied from interface:ADQLOperandTell whether this operand is a geometrical region or not.- Returns:
- true if this operand is a geometry, false otherwise.
-
getCopy
Description copied from interface:ADQLObjectGets a (deep) copy of this ADQL object.- Returns:
- The copy of this ADQL object.
- Throws:
Exception- If there is any error during the copy.
-
getName
Description copied from interface:ADQLObjectGets the name of this object in ADQL.- Returns:
- The name of this ADQL object.
-
getParameters
Description copied from class:ADQLFunctionGets the list of all parameters of this function.- Specified by:
getParametersin classADQLFunction- Returns:
- Its parameters list.
-
getNbParameters
public final int getNbParameters()Description copied from class:ADQLFunctionGets the number of parameters this function has.- Specified by:
getNbParametersin classADQLFunction- Returns:
- Number of parameters.
-
getParameter
Description copied from class:ADQLFunctionGets the index-th parameter.- Specified by:
getParameterin classADQLFunction- Parameters:
index- Parameter number.- Returns:
- The corresponding parameter.
- Throws:
ArrayIndexOutOfBoundsException- If the index is incorrect (index < 0 || index >= getNbParameters()).
-
setParameter
public ADQLOperand setParameter(int index, ADQLOperand replacer) throws ArrayIndexOutOfBoundsException, NullPointerException, Exception Function to override if you want to check the parameters of this user defined function.- Specified by:
setParameterin classADQLFunction- Parameters:
index- Index of the parameter to replace.replacer- The replacer.- Returns:
- The replaced parameter.
- Throws:
ArrayIndexOutOfBoundsException- If the index is incorrect (index < 0 || index >= getNbParameters()).NullPointerException- If a required parameter must be replaced by a NULL object.Exception- If another error occurs.- See Also:
-
translate
Description copied from class:UserDefinedFunctionTranslate this User Defined Function into the language supported by the given translator.
VERY IMPORTANT: This function MUST NOT use
ADQLTranslator.translate(UserDefinedFunction)to translate itself. The givenADQLTranslatormust be used ONLY to translate UDF's operands.Implementation example (extract of
translate(ADQLTranslator)):public String translate(final ADQLTranslator caller) throws TranslationException{ StringBuffer sql = new StringBuffer(functionName); sql.append('('); for(int i = 0; i < parameters.size(); i++){ if (i > 0) sql.append(',').append(' '); sql.append(caller.translate(parameters.get(i))); } sql.append(')'); return sql.toString(); }- Specified by:
translatein classUserDefinedFunction- Parameters:
caller- Translator to use in order to translate ONLY function parameters.- Returns:
- The translation of this UDF into the language supported by the given translator.
- Throws:
TranslationException- If one of the parameters can not be translated.
-