Thank you,
with your help, I could solve it.
It works really good.
-----Ursprüngliche Nachricht-----
Von: Alexey Zinger []
Gesendet: Donnerstag, 4. Oktober 2007 04:28
An: Finckler, Christian;
Betreff: Re: [Beanshell-users] syntax question about quick evaluation inside of java

It should be:

Interpreter i = new Interpreter();
i.set("o", new OrderDetailVO()); //normal java bean
String g = "getQuantity()";
i.eval("o." + g); // not i.eval("o.g");

"Finckler, Christian" <> wrote:
I would like to execute the following java-code:
Interpreter i = new Interpreter();
i.set("o", new OrderDetailVO()); //normal java bean
i.set("g", "getQuantity()" );

i.eval("result = o.getQuantity()");
System.out.println( i.get("result") ); //this works

i.eval("result = o.g");
System.out.println( i.get("result") ); //this not

In this code, I would like to pass an object and a method name, that should be excecuted on the given object.
The first eval-expression works fine, but with the second expression I get the following exception:
Exception in thread "main" Sourced file: inline evaluation of: ``result = o.g;'' : Cannot access field: g, on object: orderws1.OrderDetailVO@10b4199 : at Line: 1 : in file: inline evaluation of: ``result = o.g;'' : o .g

The interpreter thinks, that the letter g is an attribute instead of an inputparameter string, that should be executed as method name.

How can i tell the interpreter, that it should replace the letter g first with the given string and then evaluate the expression?

I know that I can archive that directly with java reflection, but in the end, I would like to execute statements like this on an given object: getOrder().getCustomer().getAddress().getStreet().
With java-reflection this is not possible.

Thank you for your help,

This email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>
Beanshell-users mailing list

2001 Honda CBR600F4i (CCS)
1992 Kawasaki EX500

Building a website is a piece of cake.
Yahoo! Small Business gives you all the tools to get online.