public final class DefaultUDF extends UserDefinedFunction
ADQLFunction.ParameterIterator| Modifier and Type | Field and Description |
|---|---|
protected FunctionDef |
definition
Define/Describe this user defined function.
|
protected java.lang.String |
functionName
Parsed name of this UDF.
|
protected ADQLList<ADQLOperand> |
parameters
Its parsed parameters.
|
| Constructor and Description |
|---|
DefaultUDF(DefaultUDF toCopy)
Builds a UserFunction by copying the given one.
|
DefaultUDF(java.lang.String name,
ADQLOperand[] params)
Creates a user function.
|
| Modifier and Type | Method and Description |
|---|---|
ADQLObject |
getCopy()
Gets a (deep) copy of this ADQL object.
|
FunctionDef |
getDefinition()
Get the signature/definition/description of this user defined function.
|
java.lang.String |
getName()
Gets the name of this object in ADQL.
|
int |
getNbParameters()
Gets the number of parameters this function has.
|
ADQLOperand |
getParameter(int index)
Gets the index-th parameter.
|
ADQLOperand[] |
getParameters()
Gets the list of all parameters of this function.
|
boolean |
isGeometry()
Tell whether this operand is a geometrical region or not.
|
boolean |
isNumeric()
Tell whether this operand is numeric or not.
|
boolean |
isString()
Tell whether this operand is a string or not.
|
void |
setDefinition(FunctionDef def)
Let set the signature/definition/description of this user defined function.
|
ADQLOperand |
setParameter(int index,
ADQLOperand replacer)
Function to override if you want to check the parameters of this user defined function.
|
java.lang.String |
translate(ADQLTranslator caller)
Translate this User Defined Function into the language supported by the given translator.
|
getExpectedType, setExpectedTypeadqlIterator, getPosition, paramIterator, setPosition, toADQLclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitadqlIterator, getPosition, toADQLprotected FunctionDef definition
protected final ADQLList<ADQLOperand> parameters
protected final java.lang.String functionName
public DefaultUDF(java.lang.String name,
ADQLOperand[] params)
throws java.lang.NullPointerException
params - Parameters of the function.java.lang.NullPointerExceptionpublic DefaultUDF(DefaultUDF toCopy) throws java.lang.Exception
toCopy - The UserFunction to copy.java.lang.Exception - If there is an error during the copy.public final FunctionDef getDefinition()
public final void setDefinition(FunctionDef def) throws java.lang.IllegalArgumentException
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.
def - The definition applying to this parsed UDF, or NULL if none has been found.java.lang.IllegalArgumentException - If the name in the given definition does not match the name of this parsed function.public final boolean isNumeric()
ADQLOperandpublic final boolean isString()
ADQLOperandpublic final boolean isGeometry()
ADQLOperandpublic ADQLObject getCopy() throws java.lang.Exception
ADQLObjectjava.lang.Exception - If there is any error during the copy.public final java.lang.String getName()
ADQLObjectpublic final ADQLOperand[] getParameters()
ADQLFunctiongetParameters in class ADQLFunctionpublic final int getNbParameters()
ADQLFunctiongetNbParameters in class ADQLFunctionpublic final ADQLOperand getParameter(int index) throws java.lang.ArrayIndexOutOfBoundsException
ADQLFunctiongetParameter in class ADQLFunctionindex - Parameter number.java.lang.ArrayIndexOutOfBoundsException - If the index is incorrect (index < 0 || index >= getNbParameters()).public ADQLOperand setParameter(int index, ADQLOperand replacer) throws java.lang.ArrayIndexOutOfBoundsException, java.lang.NullPointerException, java.lang.Exception
setParameter in class ADQLFunctionindex - Index of the parameter to replace.replacer - The replacer.java.lang.ArrayIndexOutOfBoundsException - If the index is incorrect (index < 0 || index >= getNbParameters()).java.lang.NullPointerException - If a required parameter must be replaced by a NULL object.java.lang.Exception - If another error occurs.ADQLFunction.setParameter(int, adql.query.operand.ADQLOperand)public java.lang.String translate(ADQLTranslator caller) throws TranslationException
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 given ADQLTranslator must 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();
}
translate in class UserDefinedFunctioncaller - Translator to use in order to translate ONLY function parameters.TranslationException - If one of the parameters can not be translated.