You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Carlos DurĂ¡n <ca...@gmail.com> on 2008/05/06 19:43:29 UTC

jexl method invocation whithout specifying the object (implicit)

Is there any way to do a jexl method invocation whithout specifying the
object?


This is how I have done it until now:

String jexlExp = "foo.bar()";
Expression e = ExpressionFactory.createExpression(jexlExp);
JexlContext jc = JexlHelper.createContext();
jc.getVars().put("foo", new Foo());
Object o = e.evaluate(jc);
System.out.println(o.toString());


But I want something like this:(This code produces errors)

String jexlExp = "bar()";
Expression e = ExpressionFactory.createExpression(jexlExp);
JexlContext jc = JexlHelper.createContext();
Object o = e.evaluate(jc);
System.out.println(o.toString());



I want  the evaluate method  to  know(in some way) that  each method  in
the  jexl expression  always refers to the class Foo (without specifying it
)