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.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 }