Package adql.query.operand.function

## Class UserDefinedFunction

- java.lang.Object
- - adql.query.operand.function.ADQLFunction
  - - adql.query.operand.function.UserDefinedFunction

- All Implemented Interfaces:
    `ADQLObject`, `ADQLOperand`, `UnknownType`
  Direct Known Subclasses:
    `DefaultUDF`

      public abstract class UserDefinedFunction
      extends ADQLFunction
      implements UnknownType

  Function defined by the user (i.e. PSQL functions).
  Version:
    1.3 (02/2015)
  Author:
    Grégory Mantelet (CDS;ARI)
  See Also:
    `DefaultUDF`

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class adql.query.operand.function.ADQLFunction

      `ADQLFunction.ParameterIterator`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `UserDefinedFunction()` |

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | 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.

    - ### Methods inherited from class adql.query.operand.function.ADQLFunction

      `adqlIterator, getNbParameters, getParameter, getParameters, getPosition, paramIterator, setParameter, setPosition, toADQL`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface adql.query.ADQLObject

      `adqlIterator, getCopy, getName, getPosition, toADQL`

    - ### Methods inherited from interface adql.query.operand.ADQLOperand

      `isGeometry, isNumeric, isString`

- - ### Constructor Detail

    - #### UserDefinedFunction

          public UserDefinedFunction()

  - ### Method Detail

    - #### getExpectedType

          public char getExpectedType()

      Description copied from interface: `UnknownType`
      Get the type expected by the syntactic parser according to the context.
      Specified by:
        `getExpectedType` in interface `UnknownType`
      Returns:
        Expected type: 'n' or 'N' for numeric, 's' or 'S' for string, 'g' or 'G' for geometry.

    - #### setExpectedType

          public void setExpectedType​(char c)

      Description copied from interface: `UnknownType`
      Set the type expected for this operand.
      Specified by:
        `setExpectedType` in interface `UnknownType`
      Parameters:
        `c` - Expected type: 'n' or 'N' for numeric, 's' or 'S' for string, 'g' or 'G' for geometry.

    - #### translate

          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();
           }

      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.
      Since:
        1.3