001package com.randomnoun.common.jexl.sql; 002 003import java.util.*; 004 005import com.randomnoun.common.jexl.eval.*; 006 007/** 008 * A function which can be translated into SQL. These functions should be 009 * set in an SqlGenerator's context to allow expressions to use those functions. 010 * 011 * <p>This class defines a number of 'standard' functions, which can be used; 012 * they subclass the functions in EvalFunction of the same name, so that they can work 013 * in both the Evaluator and SqlGenerator AST visitors. 014 * 015 * 016 * @author knoxg 017 */ 018public interface SqlFunction { 019 020 /** All SQL functions must implement this method. It returns the SQL required for 021 * the database to evaluate the function. evalContext can be used to get the 022 * database type, if required. 023 * 024 * @param functionName The name of the function being translated 025 * @param evalContext The evaluation context of the SqlGenerator doing the translation 026 * @param arguments The arguments to the function 027 * 028 * @return the SQL representation of the function 029 * @throws EvalException If an exception occured during translation (e.g. missing arguments, arguments of wrong type, invalid arguments). 030 * @throws EvalFallbackException If this expression should be evaluated at runtime instead of being translated 031 */ 032 public abstract String toSql(String functionName, EvalContext evalContext, List<Object> arguments) 033 throws EvalException, EvalFallbackException; 034}