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. package org.apache.commons.jexl;
  17. import org.apache.commons.jexl.context.HashMapContext;
  18. /**
  19. * Helper to create a context. In the current implementation of JEXL, there
  20. * is one implementation of JexlContext - {@link HashMapContext}, and there
  21. * is no reason not to directly instantiate {@link HashMapContext} in your
  22. * own application.
  23. *
  24. * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
  25. * @version $Id: JexlHelper.java,v 1.4 2004/06/12 23:53:17 tobrien Exp $
  26. */
  27. public class JexlHelper
  28. {
  29. protected static JexlHelper helper = new JexlHelper();
  30. protected static JexlHelper getInstance()
  31. {
  32. return helper;
  33. }
  34. /**
  35. * Returns a new {@link JexlContext}.
  36. * @return a new JexlContext
  37. */
  38. public static JexlContext createContext()
  39. {
  40. return getInstance().newContext();
  41. }
  42. /**
  43. * Creates and returns a new {@link JexlContext}. The current implementation
  44. * creates a new instance of {@link HashMapContext}.
  45. * @return a new JexlContext
  46. */
  47. protected JexlContext newContext()
  48. {
  49. return new HashMapContext();
  50. }
  51. }