FileDocCategorySizeDatePackage
StaticFunctionTests.javaAPI DocGlassfish v2 API4593Sat May 05 19:17:50 BST 2007org.apache.taglibs.standard.lang.jstl.test

StaticFunctionTests

public class StaticFunctionTests extends Object

This class contains some test functions.

author
Shawn Bayern

Fields Summary
Constructors Summary
Methods Summary
public static intadd(int a, int b)

    return a + b;
  
public static intgetInt(java.lang.Integer i)

    return i.intValue();
  
public static java.lang.IntegergetInteger(int i)

    return Integer.valueOf(i);
  
public static java.util.MapgetSampleMethodMap()

    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 voidmain(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 intmultiply(int a, int b)

    return a * b;