|
From: | Malik H |
Subject: | [Help-jel] Dot operators... |
Date: | Thu, 15 Aug 2002 13:24:16 -0700 (PDT) |
Konstantin:
Thanks for your email to my colleage Prem. But it appears that We are still experiecing the problem. We are trying to dynamically evaluate java _expression_ like:
"someobject.isTrue()==true" where someObject is created and registered thru Dynamic lib registration.
Similarly we get the following compilitaiion error for String object:
COMPILATION ERROR :The name "String" is unknown.
String.toString()
Here is the entire code....Please help,...
package
test;import
gnu.jel.*;import
gov.irs.efile.tfrp.dataModel.PTFResult;
public class
JelTest { public static void main(String[] args) { // Set up the library Class[] staticLib=new Class[1]; try {staticLib[0]=Class.forName(
"java.lang.String");}
catch(ClassNotFoundException e) { // Can't be ;)) ...... in java ... ;)};
Class[] dynamicLib=
new Class[1]; /*PTFResult ptfResult = new PTFResult(0, true);
Object[] context = new Object[1];
context[0]=ptfResult;
dynamicLib[0]=ptfResult.getClass();
*/
String ptfResult =
new String();Object[] context =
new Object[1];context[0]=ptfResult;
dynamicLib[0]=ptfResult.getClass();
Library lib=
new Library(null,dynamicLib,new Class[0],null,null); try {lib.markStateDependent(
"random",null);}
catch (Exception e) { // Can't be also };String testStr =
"abc"; //DVMap resolver = new DVMap();//PTFResult ptfResult = new PTFResult(0, true);
//
//String expr = "\"abc\".length()==3";
String expr =
"testStr.toString()";///"ptfResult.getIsValid()==true";//String expr = "PTFResult.getIsValid()==true";
CompiledExpression expr_c=null; try {expr_c=Evaluator.compile(expr,lib);
}
catch (CompilationException ce) {System.err.print(
"COMPILATION ERROR :");System.err.println(ce.getMessage());
System.err.print(
" ");System.err.println(expr);
int column=ce.getColumn(); // Column, where error was found for(int i=0;i<column+23-1;i++) System.err.print(' ');System.err.println(
'^');}
if (expr_c != null) { // Evaluate (Can do it now any number of times FAST !!!) Boolean result=null; try {result=(Boolean)expr_c.evaluate(
null);}
catch (Throwable e) {System.err.println(
"Exception emerged from JEL compiled"+ " code (IT'S OK) :");System.err.print(e);
}
System.err.println(
"result = " + result);}
}
}
[Prev in Thread] | Current Thread | [Next in Thread] |