01: /*
02: * Copyright 2006-2007 The Scriptella Project Team.
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: package scriptella.driver.jexl;
17:
18: import org.apache.commons.jexl.JexlContext;
19: import scriptella.driver.script.ParametersCallbackMap;
20: import scriptella.spi.ParametersCallback;
21: import scriptella.spi.QueryCallback;
22:
23: import java.util.Map;
24:
25: /**
26: * Mutable {@link org.apache.commons.jexl.JexlContext} implementation for
27: * integration into Scriptella execution environment.
28: * This class allows local variables to be set via {@link #put(String,Object)} method.
29: * <br>{@link #getParameter(String)} allows reading variables.
30: *
31: * @author Fyodor Kupolov
32: * @version 1.0
33: */
34: public final class JexlContextMap extends ParametersCallbackMap
35: implements JexlContext {
36: /**
37: * Initializes instance and set parent parameters to use in {@link #getParameter(String)}.
38: *
39: * @param parentParameters parent parameters.
40: */
41: public JexlContextMap(ParametersCallback parentParameters) {
42: super (parentParameters);
43: }
44:
45: public JexlContextMap(ParametersCallback parentParameters,
46: QueryCallback queryCallback) {
47: super (parentParameters, queryCallback);
48: }
49:
50: @SuppressWarnings("unchecked")
51: public void setVars(Map vars) {
52: clear();
53: putAll(vars);
54: }
55:
56: public Map<String, Object> getVars() {
57: return this;
58: }
59:
60: }
|