|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
[JEXL] Access to static methods?JEXL can access instance methods via the objects that are passed to
the interpreter. Is it possible to access static methods in Jexl? --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: [JEXL] Access to static methods?Yes.
See http://svn.apache.org/repos/asf/commons/proper/jexl/trunk/src/test/org/apache/commons/jexl/JexlTest.java Look for testStaticMethodInvocation and testStaticMethodInvocationOnClasses On Fri, May 9, 2008 at 1:26 AM, sebb <sebbaz@...> wrote: > JEXL can access instance methods via the objects that are passed to > the interpreter. > > Is it possible to access static methods in Jexl? > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > > -- dIon Gillard "Any sufficiently advanced technology is indistinguishable from magic" - Arthur C. Clarke 1917 - 2008 |
|
|
Re: [JEXL] Access to static methods?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? If not, it looks like one could perhaps extend FlatResolver to handle something like: systemClass=java.lang.System.class; and then use it as follows: systemClass.currentTimeMillis(); Or is this destined to fail? Or am I way off On 12/05/2008, Dion Gillard <dion@...> wrote: > Yes. > > See > http://svn.apache.org/repos/asf/commons/proper/jexl/trunk/src/test/org/apache/commons/jexl/JexlTest.java > Look for > > testStaticMethodInvocation and testStaticMethodInvocationOnClasses > > > > On Fri, May 9, 2008 at 1:26 AM, sebb <sebbaz@...> wrote: > > > JEXL can access instance methods via the objects that are passed to > > the interpreter. > > > > Is it possible to access static methods in Jexl? > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: user-unsubscribe@... > > For additional commands, e-mail: user-help@... > > > > > > > > -- > dIon Gillard > "Any sufficiently advanced technology is indistinguishable from magic" - > Arthur C. Clarke 1917 - 2008 > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: [JEXL] Access to static methods?On Mon, May 12, 2008 at 7:35 AM, sebb <sebbaz@...> 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. -Trevor --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: [JEXL] Access to static methods?On 12/05/2008, Trevor Harrison <trevorsharrison@...> wrote:
> On Mon, May 12, 2008 at 7:35 AM, sebb <sebbaz@...> 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@... > For additional commands, e-mail: user-help@... > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
| Free Forum Powered by Nabble | Forum Help |