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 * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
33 * @version $Id: Expression.java,v 1.7 2004/08/23 13:53:34 dion Exp $
34 */
35 public interface Expression
36 {
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 */
44 Object evaluate(JexlContext context) throws Exception;
45
46 /***
47 * Returns the JEXL expression this Expression was created with.
48 *
49 * @return The JEXL expression to be evaluated
50 */
51 String getExpression();
52
53 /***
54 * allows addition of a resolver to allow custom interdiction of
55 * expression evaluation
56 *
57 * @param resolver resolver to be called before Jexl expression evaluated
58 */
59 void addPreResolver(JexlExprResolver resolver);
60
61 /***
62 * allows addition of a resolver to allow custom interdiction of
63 * expression evaluation
64 *
65 * @param resolver resolver to be called if Jexl expression evaluated to null
66 */
67 void addPostResolver(JexlExprResolver resolver);
68 }