public abstract class UserDefinedFunction extends ADQLFunction implements UnknownType
DefaultUDF
ADQLFunction.ParameterIterator
Constructor and Description |
---|
UserDefinedFunction() |
Modifier and Type | Method and Description |
---|---|
char |
getExpectedType()
Get the type expected by the syntactic parser according to the context.
|
void |
setExpectedType(char c)
Set the type expected for this operand.
|
abstract java.lang.String |
translate(ADQLTranslator caller)
Translate this User Defined Function into the language supported by the given translator.
|
adqlIterator, getNbParameters, getParameter, getParameters, getPosition, paramIterator, setParameter, setPosition, toADQL
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isGeometry, isNumeric, isString
adqlIterator, getCopy, getName, getPosition, toADQL
public char getExpectedType()
UnknownType
getExpectedType
in interface UnknownType
public void setExpectedType(char c)
UnknownType
setExpectedType
in interface UnknownType
c
- Expected type: 'n' or 'N' for numeric, 's' or 'S' for string, 'g' or 'G' for geometry.public abstract java.lang.String translate(ADQLTranslator caller) throws TranslationException
Translate 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 DefaultUDF.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(); }
caller
- Translator to use in order to translate ONLY function parameters.TranslationException
- If one of the parameters can not be translated.