1 package com.randomnoun.common.jexl.sql;
2
3 import java.util.*;
4
5 import com.randomnoun.common.jexl.eval.*;
6
7 /**
8 * A function which can be translated into SQL. These functions should be
9 * set in an SqlGenerator's context to allow expressions to use those functions.
10 *
11 * <p>This class defines a number of 'standard' functions, which can be used;
12 * they subclass the functions in EvalFunction of the same name, so that they can work
13 * in both the Evaluator and SqlGenerator AST visitors.
14 *
15 *
16 * @author knoxg
17 */
18 public interface SqlFunction {
19
20 /** All SQL functions must implement this method. It returns the SQL required for
21 * the database to evaluate the function. evalContext can be used to get the
22 * database type, if required.
23 *
24 * @param functionName The name of the function being translated
25 * @param evalContext The evaluation context of the SqlGenerator doing the translation
26 * @param arguments The arguments to the function
27 *
28 * @return the SQL representation of the function
29 * @throws EvalException If an exception occured during translation (e.g. missing arguments, arguments of wrong type, invalid arguments).
30 * @throws EvalFallbackException If this expression should be evaluated at runtime instead of being translated
31 */
32 public abstract String toSql(String functionName, EvalContext evalContext, List<Object> arguments)
33 throws EvalException, EvalFallbackException;
34 }