KickJava   Java API By Example, From Geeks To Geeks.

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


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.context.HashMapContext;
20
21 /**
22  * Helper to create a context. In the current implementation of JEXL, there
23  * is one implementation of JexlContext - {@link HashMapContext}, and there
24  * is no reason not to directly instantiate {@link HashMapContext} in your
25  * own application.
26  *
27  * @since 1.0
28  * @author <a HREF="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
29  * @version $Id: JexlHelper.java 397092 2006-04-26 05:11:28Z dion $
30  */

31 public class JexlHelper {
32     /** singleton instance. */
33     protected static JexlHelper helper = new JexlHelper();
34
35     /** @return the single instance. */
36     protected static JexlHelper getInstance() {
37         return helper;
38     }
39
40     /**
41      * Returns a new {@link JexlContext}.
42      * @return a new JexlContext
43      */

44     public static JexlContext createContext() {
45         return getInstance().newContext();
46     }
47
48     /**
49      * Creates and returns a new {@link JexlContext}.
50      * The current implementation creates a new instance of
51      * {@link HashMapContext}.
52      * @return a new JexlContext
53      */

54     protected JexlContext newContext() {
55         return new HashMapContext();
56     }
57 }
58
Popular Tags