KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > jexl > ScriptImpl


1 /*
2  * Copyright 2002-2006 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
17 package org.apache.commons.jexl;
18
19 import org.apache.commons.jexl.parser.ASTJexlScript;
20
21 /**
22  * Simple script implementation.
23  * @since 1.1
24  */

25 class ScriptImpl implements Script {
26
27     /** text of the script. */
28     private final String JavaDoc text;
29     /** syntax tree. */
30     private final ASTJexlScript parsedScript;
31     
32     /**
33      * Create a new Script from the given string and parsed syntax.
34      * @param scriptText the text of the script.
35      * @param scriptTree the parsed script.
36      */

37     public ScriptImpl(String JavaDoc scriptText, ASTJexlScript scriptTree) {
38         text = scriptText;
39         parsedScript = scriptTree;
40     }
41
42     /**
43      * {@inheritDoc}
44      */

45     public Object JavaDoc execute(JexlContext context) throws Exception JavaDoc {
46         // TODO Auto-generated method stub
47
return parsedScript.value(context);
48     }
49
50     /**
51      * {@inheritDoc}
52      */

53     public String JavaDoc getText() {
54         return text;
55     }
56
57 }
58
Popular Tags