01: /*
02: * Copyright 2002-2006 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.apache.commons.jexl;
18:
19: /**
20: * <p>
21: * Represents a single JEXL expression. This simple interface
22: * provides access to the underlying expression through getExpression(),
23: * and it provides hooks to add a pre- and post- expression resolver.
24: * </p>
25: *
26: * <p>
27: * An expression is different than a script - it is simply a reference of
28: * an expression.
29: * </p>
30: *
31: * @since 1.0
32: * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
33: * @version $Id: Expression.java 397092 2006-04-26 05:11:28Z dion $
34: */
35: public interface Expression {
36: /**
37: * Evaluates the expression with the variables contained in the
38: * supplied {@link JexlContext}.
39: *
40: * @param context A JexlContext containing variables.
41: * @return The result of this evaluation
42: * @throws Exception on any error
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
66: * evaluated to null.
67: */
68: void addPostResolver(JexlExprResolver resolver);
69: }
|