You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Shinobu Kawai <sh...@gmail.com> on 2004/09/26 11:30:25 UTC

ArrayTool

Hi all,

In case anyone is interested, I made a cool tool that works with
arrays.  As of the moment, there is no documentation except for the
tests.
The class:
http://sylow.no-ip.com/pub/apache/jakarta/velocity/tools/ArrayTool.java
The test:
http://sylow.no-ip.com/pub/apache/jakarta/velocity/tools/ArrayToolTest.java

Simple manual:
- Putting the tool in the context.
   context.put("arrays", new ArrayTool());
- Using it.  (Assuming that $array is an array)
-- Converting an array to a List:
   $set($list = $arrays.list($array))
-- Getting the 3rd (actually the 4th) element:
   $arrays.get($array, 3)
-- Getting the length:
   $arrays.length($array)

$array can be an instance of a List, of an array.  If it's an array of
a primitive type, it will wrap the elements.

Any comments welcome.

Best regards,
-- Shinobu Kawai

-- 
Shinobu Kawai(shinobu.kawai@gmail.com)

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


Re: ArrayTool

Posted by Shinobu Kawai <sh...@gmail.com>.
Hi all,

> $array can be an instance of a List, of an array.
I meant "OR an array", of course.  ;-)

Best regards,
-- Shinobu Kawai

-- 
Shinobu Kawai(shinobu.kawai@gmail.com)

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