001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018package org.apache.commons.jexl; 019 020import org.apache.commons.jexl.context.HashMapContext; 021 022/** 023 * Helper to create a context. In the current implementation of JEXL, there 024 * is one implementation of JexlContext - {@link HashMapContext}, and there 025 * is no reason not to directly instantiate {@link HashMapContext} in your 026 * own application. 027 * 028 * @since 1.0 029 * 030 * @version $Id$ 031 */ 032public class JexlHelper { 033 /** singleton instance. */ 034 protected static JexlHelper helper = new JexlHelper(); 035 036 /** @return the single instance. */ 037 protected static JexlHelper getInstance() { 038 return helper; 039 } 040 041 /** 042 * Returns a new {@link JexlContext}. 043 * @return a new JexlContext 044 */ 045 public static JexlContext createContext() { 046 return getInstance().newContext(); 047 } 048 049 /** 050 * Creates and returns a new {@link JexlContext}. 051 * The current implementation creates a new instance of 052 * {@link HashMapContext}. 053 * @return a new JexlContext 054 */ 055 protected JexlContext newContext() { 056 return new HashMapContext(); 057 } 058}