commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: [JEXL] Access to static methods?
Date Mon, 12 May 2008 15:12:56 GMT
On 12/05/2008, Trevor Harrison <trevorsharrison@gmail.com> wrote:
> On Mon, May 12, 2008 at 7:35 AM, sebb <sebbaz@gmail.com> wrote:
>  > I see, thanks, very useful.
>  >
>  >  Presumably Jexl has to be given class objects for any static methods
>  >  it needs to call?
>  >  Or are there any objects which are built-in to Jexl?
>
>
> Doesn't matter, you can get access to any objects you need on the fly
>  with something like:
>
>  i = 0;
>  intClazz = i.class;
>  clazz = intClazz.forName("java.io.File");
>  m = clazz.getMethod("listRoots", null);
>  roots = m.invoke(null, null);
>  files = roots[0].listFiles();
>  foreach( file in files )
>  {
>   // do something with the file
>  }
>
>  Just replace the java.io.File string with the class you are interested
>  in, and use the reflection api.
>

Thanks, that's clever ...

>
>  -Trevor
>

;-)

>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>  For additional commands, e-mail: user-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message