Interface EvalFunction

All Known Implementing Classes:
EndsWithFunction, EndsWithFunction, LikeFunction, LikeFunction, StartsWithFunction, StartsWithFunction

public interface EvalFunction
This class encapsulates a function, which is intended to be placed in an EvalContext (using EvalContext.setFunctions()). Any expression evaluated in that context will then be able to invoke developer-defined functions.
    Map<String, EvalFunction> functions = new HashMap();
    functions.put("length", new LengthFunction());
    functions.put("like", new LikeFunction());
    EvalContext evalContext = new EvalContext();
    evalContext.setFunctions(functions);
 
Some functions can also generate SQL, see SqlFunction.
Author:
knoxg
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.apache.log4j.Logger
    Logger for this class
  • Method Summary

    Modifier and Type
    Method
    Description
    evaluate(String functionName, EvalContext context, List<Object> arguments)
    This is the main entry point for classes that implement this interface.
  • Field Details

    • logger

      static final org.apache.log4j.Logger logger
      Logger for this class
  • Method Details

    • evaluate

      Object evaluate(String functionName, EvalContext context, List<Object> arguments) throws EvalException
      This is the main entry point for classes that implement this interface. The evaluate method performs the evaluation of the function that this class implements (and is supplied the functionName, so that the same class may evaluate multiple functions).
      Parameters:
      functionName - The name of the function to be evaluated (can be disregarded if this class only performs a single function)
      context - The context in which the function is being executed (could hold things like local variable values, current line number, etc...)
      arguments - The arguments passed to this function
      Returns:
      The result of the evaluation
      Throws:
      EvalException - An exception occurred during evaluation