| Tool for working with arrays in Velocity templates.
It provides a method to get and set specified elements,
retrieve the length, and create clones of an array object.
Also provides a method to convert arrays into java.util.List's.
Example uses:
$primes -> new int[] {2, 3, 5, 7}
$array.length($primes) -> 4
$array.get($primes, 2) -> 5
$array.clone($primes) -> int[] {2, 3, 5, 7}, != $primes
$array.set($primes, 2, 1) -> (primes[2] becomes 1)
$array.get($primes, 2) -> 1
$array.get($clone, 2) -> 5
Example toolbox.xml config (if you want to use this with VelocityView):
<tool>
<key>array</key>
<scope>application</scope>
<class>org.apache.velocity.tools.generic.ArrayTool</class>
</tool>
This tool is entirely threadsafe, and has no instance members.
It may be used in any scope (request, session, or application).
author: Shinobu Kawai |