StaticFunctionTestspublic class StaticFunctionTests extends Object This class contains some test functions. |
Methods Summary |
---|
public static int | add(int a, int b)
return a + b;
| public static int | getInt(java.lang.Integer i)
return i.intValue();
| public static java.lang.Integer | getInteger(int i)
return Integer.valueOf(i);
| public static java.util.Map | getSampleMethodMap()
Map m = new HashMap();
Class c = StaticFunctionTests.class;
m.put("foo:add",
c.getMethod("add", new Class[] { Integer.TYPE, Integer.TYPE }));
m.put("foo:multiply",
c.getMethod("multiply", new Class[] { Integer.TYPE, Integer.TYPE }));
m.put("foo:getInt",
c.getMethod("getInt", new Class[] { Integer.class }));
m.put("foo:getInteger",
c.getMethod("getInteger", new Class[] { Integer.TYPE }));
return m;
| public static void | main(java.lang.String[] args)
Map m = getSampleMethodMap();
Evaluator e = new Evaluator();
Object o;
o = e.evaluate("", "4", Integer.class, null, null, m, "foo");
System.out.println(o);
o = e.evaluate("", "${4}", Integer.class, null, null, m, "foo");
System.out.println(o);
o = e.evaluate("", "${2+2}", Integer.class, null, null, m, "foo");
System.out.println(o);
o = e.evaluate("", "${foo:add(2, 3)}", Integer.class, null, null, m, "foo");
System.out.println(o);
o = e.evaluate("", "${foo:multiply(2, 3)}", Integer.class, null, null, m, "foo");
System.out.println(o);
o = e.evaluate("", "${add(2, 3)}", Integer.class, null, null, m, "foo");
System.out.println(o);
o = e.evaluate("", "${multiply(2, 3)}", Integer.class, null, null, m, "foo");
System.out.println(o);
o = e.evaluate("", "${add(2, 3) + 5}", Integer.class, null, null, m, "foo");
System.out.println(o);
System.out.println("---");
o = e.evaluate("", "${getInt(getInteger(getInt(5)))}", Integer.class, null, null, m, "foo");
System.out.println(o);
o = e.evaluate("", "${getInteger(getInt(getInteger(5)))}", Integer.class, null, null, m, "foo");
System.out.println(o);
o = e.evaluate("", "${getInt(getInt(getInt(5)))}", Integer.class, null, null, m, "foo");
System.out.println(o);
o = e.evaluate("", "${getInteger(getInteger(getInteger(5)))}", Integer.class, null, null, m, "foo");
System.out.println(o);
| public static int | multiply(int a, int b)
return a * b;
|
|