1
2
3
4
5
6
7
8
9
10
11
12
13
14
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 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 scriptText, ASTJexlScript scriptTree) {
38 text = scriptText;
39 parsedScript = scriptTree;
40 }
41
42 /***
43 * {@inheritDoc}
44 */
45 public Object execute(JexlContext context) throws Exception {
46
47 return parsedScript.value(context);
48 }
49
50 /***
51 * {@inheritDoc}
52 */
53 public String getText() {
54 return text;
55 }
56
57 }