Interface FunctionTranslator

All Known Implementing Classes:
FunctionTranslatorWithPattern

public interface FunctionTranslator
Interface for a custom ADQL function translation.

Implementations

An implementation of this interface is already provided by VOLLT: FunctionTranslatorWithPattern. It lets translate a function by applying a simple string pattern with $i variables to match function arguments.

Implementation example

If the default ADQL function translation was provided by an implementation of this interface, it would look like the following:

 public class DefaultFunctionTranslator implements FunctionTranslator {

        public DefaultFunctionTranslator(){}

        public String translate(final ADQLFunction fct, final ADQLTranslator caller) throws TranslationException{
                final StringBuilder sql = new StringBuilder(fct.getName());
                sql.append('(');
                for(int i = 0; i < fct.getNbParameters(); i++){
                        if (i > 0)
                                sql.append(',').append(' ');
                        sql.append(caller.translate(fct.getParameter(i)));
                }
                sql.append(')');
                return sql.toString();
        }

 }
 
Since:
2.0
  • Method Summary

    Modifier and Type
    Method
    Description
    Translate the given ADQL function into the language supported by the given translator.
  • Method Details

    • translate

      String translate(ADQLFunction fct, ADQLTranslator caller) throws TranslationException
      Translate the given ADQL function into the language supported by the given translator.

      VERY IMPORTANT: This function MUST NOT use ADQLTranslator.translate(ADQLFunction) to translate the given ADQLFunction. The given ADQLTranslator must be used ONLY to translate the function's parameters.

      Parameters:
      fct - The function to translate.
      caller - Translator to use in order to translate ONLY function parameters.
      Returns:
      The translation of this function into the language supported by the given translator, or NULL to let the calling translator apply a default translation.
      Throws:
      TranslationException - If the translation fails.