[Mc4j-cvs] mc4j/modules/ems/src/ems/org/mc4j/ems/access Lookup.java,1.1,1.2 test.java,1.1,1.2
Brought to you by:
ghinkl
From: Greg H. <gh...@us...> - 2006-04-12 19:11:40
|
Update of /cvsroot/mc4j/mc4j/modules/ems/src/ems/org/mc4j/ems/access In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18666/modules/ems/src/ems/org/mc4j/ems/access Added Files: Lookup.java test.java Log Message: Merging EMS into head for the 2.0 release work --- NEW FILE: Lookup.java --- /* * Copyright 2002-2004 Greg Hinkle * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.mc4j.ems.access; import ognl.Ognl; import ognl.OgnlException; import java.util.Map; import java.util.HashMap; /** * @author Greg Hinkle (gh...@us...), Apr 12, 2005 * @version $Revision: 1.2 $($Author: ghinkl $ / $Date: 2006/04/12 19:11:35 $) */ public class Lookup { private static Lookup INSTANCE = new Lookup(); public static Lookup getLookup() { return INSTANCE; } public Object lookup(String ognlExpression, Map contex) { try { Object expression = Ognl.parseExpression(ognlExpression); Object value = Ognl.getValue(expression, contex); return value; } catch (OgnlException e) { e.printStackTrace(); } return null; } public static void main(String[] args) { Map context = new HashMap(); context.put("a",new Integer(3)); context.put("b","hello, world!"); context.put("c",new String[] { "one", "two", "three", "four" }); System.out.println("Value is: " + Lookup.getLookup().lookup("c[3]",context)); System.out.println("Value is: " + Lookup.getLookup().lookup("c[3] = 'hi there'",context)); System.out.println("Value is: " + Lookup.getLookup().lookup("c[3]",context)); } } --- NEW FILE: test.java --- /* * Copyright 2002-2004 Greg Hinkle * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.mc4j.ems.access; /** * @author Greg Hinkle (gh...@us...), Apr 20, 2005 * @version $Revision: 1.2 $($Author: ghinkl $ / $Date: 2006/04/12 19:11:35 $) */ public class test { public static void main(String[] args) { boolean a = true,b = false; System.out.println(a != b); } } |