Quantcast

Newbie question: evaluating java expression with my static a method

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Newbie question: evaluating java expression with my static a method

will_luu
I keep getting 'undefined variable or class name' around myUtil.getValue static method for the following expression. getValue is a static method that is from another package and I want to use it as part of my expression. How do I resolve the error?  Thanks.


String myExpression = "if (myUtil.getValue(\"person.age\", person) == 21) { canGamble = true;}"

Interpreter interpret = new Interpreter();
interpret.set("person", person);
interpret.eval(myExpression);
System.out.print(interpret.get("canGamble"));
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Newbie question: evaluating java expression with my static a method

will_luu
Never mind. I found out that I had to add the import to the package as part of myExpression string.

will_luu wrote
I keep getting 'undefined variable or class name' around myUtil.getValue static method for the following expression. getValue is a static method that is from another package and I want to use it as part of my expression. How do I resolve the error?  Thanks.


String myExpression = "if (myUtil.getValue(\"person.age\", person) == 21) { canGamble = true;}"

Interpreter interpret = new Interpreter();
interpret.set("person", person);
interpret.eval(myExpression);
System.out.print(interpret.get("canGamble"));
Loading...