Class UserDefinedFunction

    • 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