Dymanic if statement evaluation problem with string comparison

Manikandan R <[email protected]> Sat, 15 May 2010 09:17:35 +0530
Newsgroups gmane.comp.java.beanshell.user
Message-ID <[email protected]>
Hi Everyone,

I am able to do the string comparison using eval function with string
methods something like string.equals("test"), but not able to do something
like string == "test".

Here is the code which works fine - getting the success as output:

String s = "test";

String cond = "s.equals(\"test\")";

Interpreter i = new Interpreter();

i.set("s", s);
if((Boolean)i.eval(cond)) {
   System.out.println("success");
} else {
   System.out.println("fail");
}

Can anyone help me onhow to achieve the same using without string equals
method?
Thanks,
Mani
------------------------------------------------------------------------------