Re: A newbie question related to using bsh
Neo Anderson <javadeveloper999-/[email protected]> Wed, 5 Aug 2009 15:40:52 +0000 (GMT)
| Newsgroups | gmane.comp.java.beanshell.user |
|---|---|
| Message-ID | <[email protected]> |
But how if those scripts would return variant types? For instance, there ar=
e 3 bsh scripts I want to collect. So in the Java application I might scan =
the dir and use =
for(...){
Object result =3D bsh.Interpreter().source(BshFileNames);
}
So the result object would be different kind of type e.g. class A, class B =
and Class C. =
Is there any chance that I can cast them dynamically?
Thanks to reply my question.
--- On Wed, 5/8/09, KUN LI <[email protected]> wrote:
> From: KUN LI <[email protected]>
> Subject: RE: [Beanshell-users] A newbie question related to using bsh
> To: javadeveloper999-/[email protected], "beanshell - users" <beanshell-users@li=
sts.sourceforge.net>
> Date: Wednesday, 5 August, 2009, 3:34 PM
> =
> =
> =
> #yiv1311021128 .hmmessage P
> {
> margin:0px;padding:0px;}
> #yiv1311021128 {
> font-size:10pt;font-family:Verdana;}
> =
> =
> =
> You can use "Collection" which can be a
> "List" or "Vector".
> =
> Example:
> =
> Collection<A> results =3D new Arraylist();
> =
> results.add(result);
> =
> Kun LI
> =
> =
> =
> =
> > Date: Wed, 5 Aug 2009 15:22:02 +0000
> > From: javadeveloper999-/[email protected]
> > To: Beanshell-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> > Subject: [Beanshell-users] A newbie question related
> to using bsh
> > =
> > =
> > I read the doc at
> http://www.beanshell.org/examples/callscript.html. But this
> arises me a question. How can I cast the result object into
> the type I want? For instance, in the script I finally have
> type A created, then in the Java application I obtained
> using the following statement
> > =
> > Object result =3D new
> bsh.Interpreter().source("myscript.bsh");
> > =
> > I can cast result to A if I only have one script e.g.
> > =
> > A a =3D (A) result;
> > =
> > However, how if I want to collect many scripts once
> and then cast all object collected into type desired?
> > =
> > Is there any way I can achieve this?
> > =
> > Thanks for help.
> > =
> > =
> > =
> > =
> > =
> > =
> >
> -------------------------------------------------------------------------=
-----
> > Let Crystal Reports handle the reporting - Free
> Crystal Reports 2008 30-Day =
> > trial. Simplify your report design, integration and
> deployment - and focus on =
> > what you do best, core application coding. Discover
> what's new with =
> > Crystal Reports now. http://p.sf.net/sfu/bobj-july
> > _______________________________________________
> > Beanshell-users mailing list
> > Beanshell-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> >
> https://lists.sourceforge.net/lists/listinfo/beanshell-users
> =
> Discutez sur Messenger o=F9 que vous soyez ! Mettez
> Messenger sur votre mobile ! =
> =
=
---------------------------------------------------------------------------=
---
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day =
trial. Simplify your report design, integration and deployment - and focus =
on =
what you do best, core application coding. Discover what's new with =
Crystal Reports now. http://p.sf.net/sfu/bobj-july