View Javadoc

1   /*
2    *
3    *   Copyright 2006 The Apache Software Foundation.
4    *
5    *  Licensed under the Apache License, Version 2.0 (the "License");
6    *  you may not use this file except in compliance with the License.
7    *  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   *  Unless required by applicable law or agreed to in writing, software
12   *  distributed under the License is distributed on an "AS IS" BASIS,
13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   *  See the License for the specific language governing permissions and
15   *  limitations under the License.
16   *
17   */
18  package org.apache.commons.scxml.env.jexl;
19  
20  import java.util.Map;
21  
22  import org.apache.commons.scxml.Builtin;
23  import org.apache.commons.scxml.Context;
24  import org.apache.commons.scxml.env.SimpleContext;
25  
26  /***
27   * JEXL Context implementation for Commons SCXML.
28   *
29   */
30  public class JexlContext extends SimpleContext
31      implements org.apache.commons.jexl.JexlContext {
32  
33      /***
34       * Constructor.
35       */
36      public JexlContext() {
37          super();
38          getVars().put("_builtin", new Builtin());
39      }
40  
41      /***
42       * Constructor with initial vars.
43       *
44       * @param initialVars The initial set of variables.
45       */
46      public JexlContext(final Map initialVars) {
47          super(initialVars);
48          getVars().put("_builtin", new Builtin());
49      }
50  
51      /***
52       * Constructor with parent context.
53       *
54       * @param parent The parent context.
55       */
56      public JexlContext(final Context parent) {
57          super(parent);
58          getVars().put("_builtin", new Builtin());
59      }
60  
61      /***
62       * Set the variables map.
63       *
64       * @param vars The new variables map.
65       *
66       * @see org.apache.commons.jexl.JexlContext#setVars(Map)
67       * @see org.apache.commons.scxml.env.SimpleContext#setVars(Map)
68       */
69      public void setVars(final Map vars) {
70          super.setVars(vars);
71          getVars().put("_builtin", new Builtin());
72      }
73  
74      /***
75       * Get the variables map.
76       *
77       * @return Map The variables map.
78       *
79       * @see org.apache.commons.jexl.JexlContext#getVars()
80       * @see org.apache.commons.scxml.env.SimpleContext#getVars()
81       */
82      public Map getVars() {
83          return super.getVars();
84      }
85  
86      /***
87       * Clear this Context.
88       *
89       * @see org.apache.commons.scxml.Context#reset()
90       */
91      public void reset() {
92          super.reset();
93          getVars().put("_builtin", new Builtin());
94      }
95  
96  }
97