use of org.apache.taglibs.standard.lang.jstl.Evaluator in project opennms by OpenNMS.
the class StaticFunctionTests method main.
public static void main(String[] args) throws Exception {
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);
}
use of org.apache.taglibs.standard.lang.jstl.Evaluator in project opennms by OpenNMS.
the class EvaluationTest method runTests.
// -------------------------------------
/**
* Runs the tests, reading expressions from pIn and writing the
* results to pOut.
*/
public static void runTests(DataInput pIn, PrintStream pOut) throws IOException {
PageContext context = createTestContext();
while (true) {
String str = pIn.readLine();
if (str == null)
break;
if (str.startsWith("#") || "".equals(str.trim())) {
pOut.println(str);
} else {
String typeStr = pIn.readLine();
pOut.println("Expression: " + str);
try {
Class cl = parseClassName(typeStr);
pOut.println("ExpectedType: " + cl);
Evaluator e = new Evaluator();
Object val = e.evaluate("test", str, cl, null, context);
pOut.println("Evaluates to: " + val);
if (val != null) {
pOut.println("With type: " + val.getClass().getName());
}
pOut.println();
} catch (JspException exc) {
pOut.println("Causes an error: " + exc);
} catch (ClassNotFoundException exc) {
pOut.println("Causes an error: " + exc);
}
}
}
}
Aggregations