You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Geir Magnusson Jr." <ge...@adeptra.com> on 2003/04/05 01:03:35 UTC
Re: [jexl] arrays?
This would be of much use, wouldn't it...
On Friday, March 28, 2003, at 06:38 PM, Mark R. Diggory wrote:
> Maybe if I give brief example I can get an answer, I have the
> following situation where I'd like to use a double[] to instantiate
> into a property of a target.
>
> <j:set target="${model}" property="landReproductionTable"
> value="${LR0}, ${LR1}, ${LR2}, ${LR3}, ${LR4}"/>
>
> currently, I've been handing it in as a string and parsinging it
> internally in the object back into a double[]. Since JEXL's site is
> limited in its documentation, I cannot see if it is possible to do
> something like the following instead:
>
> <j:set target="${model}" property="landReproductionTable" value="${[
> LR0, LR1, LR2, LR3, LR4]}"/>
Yes, we can add the [ <ref> [, <ref>]* ] (whatever :) - I can't see
much of a downside there. We do the same thing in Velocity and it's
very useful.
We also allow ranges with similar notation -
[1..10]
returns an ArrayList with Integers 1..20 inclusive
the one question I'd ask is what would the array be? In vel we use an
j.u.ArraList as the implementation, rather than an array [], which I
think is much nicer.
Comments?
>
> -Mark
>
> Mark R. Diggory wrote:
>> Is there a way to deal with creating arrays in jexl?
>> I'm used to doing things like this in java inlines
>> new String[]{"foo","bar"};
>> Something similar in JEXL would be very powerfull.
>> -Mark
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
--
Geir Magnusson Jr 203-956-2604(w)
Adeptra, Inc. 203-434-2093(m)
geirm@adeptra.com 203-247-1713(m)
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [jexl] arrays?
Posted by "Mark R. Diggory" <md...@latte.harvard.edu>.
Geir Magnusson Jr. wrote:
> This would be of much use, wouldn't it...
>
> Yes, we can add the [ <ref> [, <ref>]* ] (whatever :) - I can't see
> much of a downside there. We do the same thing in Velocity and it's
> very useful.
>
> We also allow ranges with similar notation -
>
> [1..10]
>
> returns an ArrayList with Integers 1..20 inclusive
>
> the one question I'd ask is what would the array be? In vel we use an
> j.u.ArraList as the implementation, rather than an array [], which I
> think is much nicer.
>
> Comments?
Great, thanks for the response.
While an ArrayList is probibly the most generic solution, optimal
solutions could "save memory" by detecting and instantiating an array of
the proper type. Take situations like this:
<j:set target="${model}" property="foo" value="${[1..500]}"/>
If foo is of type int[] it would be reasonable to instantiate the
appropriate int[] for that particular "return".
Its tough, at first I was thinking that in Jelly the object that is
being "targeted" with the "property" will have a getter/setter of a
specific type { primitive[] or ArrayList... }. But JEXL probibly has no
detection concerning this type (Does it?). I wish it were possible to
determine a return type of the evaluation and somehow return an object
of that specific type.
If there's no return type detection in JEXL, then maybe there's some
solution available in the "syntax"
double[ 0.1, 0.2 ] --> a double[]
int[ 1, 2 ] --> an int[]
primitive[...] --> ...
[1, 2, 3] --> an ArrayList
I really like the ranges idea as well and could really use a feature
like that in my modelling taglibrary.
If its something thats relatively easy to do, great. I might be able to
volunteer some dev time if you would like a hand. I did some primitive[]
type detection in my BCEL taglibrary and in a Swing TableModel dealing
getting/setting primitive Arrays in objects via table models.
-thanks,
Mark Diggory
http://repast-jellytag.sourceforge.net
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org