1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.jelly.expression;
17
18 import java.util.Iterator;
19
20 import org.apache.commons.jelly.JellyContext;
21
22 /*** <p><code>Expression</code> represents an arbitrary expression using some pluggable
23 * expression language.</p>
24 *
25 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
26 * @version $Revision: 155420 $
27 */
28 public interface Expression {
29
30 /***
31 * @return the textual representation of this expression
32 */
33 public String getExpressionText();
34
35 /***
36 * Evaluates the expression with the given context
37 * and returns the result
38 */
39 public Object evaluate(JellyContext context);
40
41 /***
42 * Evaluates the expression with the given context
43 * coercing the result to be a String.
44 */
45 public String evaluateAsString(JellyContext context);
46
47 /***
48 * Evaluates the expression with the given context
49 * coercing the result to be a boolean.
50 */
51 public boolean evaluateAsBoolean(JellyContext context);
52
53 /***
54 * Evaluates the expression with the given context
55 * coercing the result to be an Iterator.
56 */
57 public Iterator evaluateAsIterator(JellyContext context);
58
59 /***
60 * This method evaluates the expression until a value (a non-Expression) object
61 * is returned.
62 * If the expression returns another expression, then the nested expression is evaluated.
63 * <p>
64 * Sometimes when Jelly is used inside Maven the value
65 * of an expression can actually be another expression.
66 * For example if a properties file is read, the values of variables
67 * can actually be expressions themselves.
68 * <p>
69 * e.g. ${foo.bar} can lookup "foo.bar" in a Maven context
70 * which could actually be another expression.
71 * <p>
72 * So using this method, nested expressions can be evaluated to the
73 * actual underlying value object.
74 */
75 public Object evaluateRecurse(JellyContext context);
76 }