View Javadoc

    1   /*
    2    * Copyright 2002,2004 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   *  @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
    28   *  @version $Id: JexlHelper.java,v 1.4 2004/06/12 23:53:17 tobrien Exp $
    29   */
    30  public class JexlHelper
    31  {
    32      protected static JexlHelper helper = new JexlHelper();
    33
    34      protected static JexlHelper getInstance()
    35      {
    36          return helper;
    37      }
    38
    39      /***
    40       * Returns a new {@link JexlContext}.
    41       * @return a new JexlContext
    42       */
    43      public static JexlContext createContext()
    44      {
    45          return getInstance().newContext();
    46      }
    47
    48      /***
    49       * Creates and returns a new {@link JexlContext}.  The current implementation
    50       * creates a new instance of {@link HashMapContext}.
    51       * @return a new JexlContext
    52       */
    53      protected JexlContext newContext()
    54      {
    55          return new HashMapContext();
    56      }
    57  }