KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > webwork > views > jsp > ui > OgnlTool


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 package com.opensymphony.webwork.views.jsp.ui;
6
7 import com.opensymphony.xwork.util.OgnlUtil;
8 import ognl.Ognl;
9 import ognl.OgnlException;
10
11
12 /**
13  * @author Matt Ho <a HREF="mailto:matt@enginegreen.com">&lt;matt@enginegreen.com&gt;</a>
14  * @version $Id: OgnlTool.java,v 1.5 2004/10/02 05:40:05 jcarreira Exp $
15  */

16 public class OgnlTool {
17     //~ Static fields/initializers /////////////////////////////////////////////
18

19     private static OgnlTool instance = new OgnlTool();
20
21     //~ Constructors ///////////////////////////////////////////////////////////
22

23     private OgnlTool() {
24     }
25
26     //~ Methods ////////////////////////////////////////////////////////////////
27

28     public static OgnlTool getInstance() {
29         return instance;
30     }
31
32     public Object JavaDoc findValue(String JavaDoc expr, Object JavaDoc context) {
33         try {
34             return Ognl.getValue(OgnlUtil.compile(expr), context);
35         } catch (OgnlException e) {
36             return null;
37         }
38     }
39 }
40
Popular Tags