KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > script > ExpressionEvaluator


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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  * $Header:$
17  */

18 package org.apache.beehive.netui.script;
19
20 import javax.servlet.jsp.el.VariableResolver JavaDoc;
21
22 /**
23  * An interface for evaluating expressions in NetUI. Different languages may implement
24  * this to expose the language for use in the NetUI JSP tags.
25  */

26 public interface ExpressionEvaluator {
27
28     /**
29      * Evaluate an expression and return the result.
30      *
31      * @param expression the expression to evaluate
32      * @param variableResolver the set of contexts that may be used in expression evaluation. This set
33      * is not necessarily complete as some objects that can be used as top-level expression contexts
34      * may be contained within an object available in this JavaBean.
35      * @throws ExpressionEvaluationException when an error occurs
36      */

37     public Object JavaDoc evaluateStrict(String JavaDoc expression, VariableResolver JavaDoc variableResolver)
38         throws ExpressionEvaluationException;
39
40     /**
41      * Update an expression with the given value. This will apply the parameter <code>value</code>
42      * to the object referenced by the expression <code>expression</code>. The <code>requestParameter</code>
43      * flag is used by a caller to restrict the set of contexts into which an update can occur on
44      * the request.
45      *
46      * @param expression the expression whose value to update
47      * @param value the new value for the update
48      * @param variableResolver the set of contexts that may be used in expression evaluation. This set
49      * is not necessarily complete as some objects that can be used as top-level expression contexts
50      * may be contained within an object available in this JavaBean.
51      * @param requestParameter a boolean that marks this update as occurring from data in the request, if
52      * <code>true</code> or simply as a regular update.
53      */

54     public void update(String JavaDoc expression, Object JavaDoc value, VariableResolver JavaDoc variableResolver, boolean requestParameter)
55         throws ExpressionUpdateException;
56
57     /**
58      * Change the evaluation context of an expression. This is used to rewrite some expressions
59      * that need to be qualified into a different context for evaluation. The context
60      * of an expression is its first identifier, up to the first delimiter.
61      *
62      * @param expression the expression whose context to change
63      * @param oldContext the old context to replace, if present
64      * @param newContext the new context to replace if the expression starts with the <code>oldContext</code>
65      * @param lookupIndex an index used to qualify an expression into an array look-up.
66      * @exclude
67      */

68     public String JavaDoc changeContext(String JavaDoc expression, String JavaDoc oldContext, String JavaDoc newContext, int lookupIndex)
69         throws ExpressionEvaluationException;
70
71     /**
72      * Qualify the expression into the given context. This will take the <code>expression</code>
73      * and simply qualify it into the new context <code>contextName</code>.
74      *
75      * @param contextName the new context
76      * @param expression the expression to qualify
77      * @exclude
78      */

79     public String JavaDoc qualify(String JavaDoc contextName, String JavaDoc expression)
80         throws ExpressionEvaluationException;
81
82     /**
83      * Checks to see if a particular String is exactly an expression.
84      *
85      * @param expression the expression to check
86      * @return <code>true</code> if the expression is exactly an expression; <code>false</code> otherwise.
87      * @throws IllegalExpressionException if the given expression <code>expression</code> is not legal.
88      */

89     public boolean isExpression(String JavaDoc expression);
90
91     /**
92      * Checks to see if a particular expression contains an expression. This method will return
93      * <code>true</code> if there is an expression surrounded by whitespace, other expressions,
94      * or literal text.
95      *
96      * @param expression the expression to check
97      * @return <code>true</code> if the expression contains an expression; <code>false</code> otherwise.
98      */

99     public boolean containsExpression(String JavaDoc expression);
100
101     /**
102      * Parse an atomic expression into a common parsed expression
103      * representation.
104      *
105      * @param expression the String expression to parse
106      * @return the parsed expression
107      */

108     public Expression parseExpression(String JavaDoc expression);
109 }
110
Popular Tags