1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  
17  package org.apache.commons.jexl;
18  
19  
20  /***
21   * <p>
22   * Represents a single JEXL expression.  This simple interface
23   * provides access to the underlying expression through getExpression(),
24   * and it provides hooks to add a pre- and post- expression resolver.
25   * </p>
26   *
27   * <p>
28   * An expression is different than a script - it is simply a reference of
29   * an expression.
30   * </p>
31   *
32   * @since 1.0
33   * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
34   * @version $Id: Expression.java 397092 2006-04-26 05:11:28Z dion $
35   */
36  public interface Expression {
37      /***
38       * Evaluates the expression with the variables contained in the
39       * supplied {@link JexlContext}.
40       *
41       * @param context A JexlContext containing variables.
42       * @return The result of this evaluation
43       * @throws Exception on any error
44       */
45      Object evaluate(JexlContext context) throws Exception;
46  
47      /***
48       * Returns the JEXL expression this Expression was created with.
49       *
50       * @return The JEXL expression to be evaluated
51       */
52      String getExpression();
53  
54      /***
55       * Allows addition of a resolver to allow custom interdiction of
56       * expression evaluation.
57       *
58       * @param resolver resolver to be called before Jexl expression evaluated
59       */
60      void addPreResolver(JexlExprResolver resolver);
61  
62      /***
63       * Allows addition of a resolver to allow custom interdiction of
64       * expression evaluation.
65       *
66       * @param resolver resolver to be called if Jexl expression
67       *  evaluated to null.
68       */
69      void addPostResolver(JexlExprResolver resolver);
70  }