| Tool for working with Lists and arrays in Velocity templates.
It provides a method to get and set specified elements.
Also provides methods to perform the following actions to Lists and arrays:
- Check if it is empty.
- Check if it contains a certain element.
Example uses:
$primes -> new int[] {2, 3, 5, 7}
$list.size($primes) -> 4
$list.get($primes, 2) -> 5
$list.set($primes, 2, 1) -> (primes[2] becomes 1)
$list.get($primes, 2) -> 1
$list.isEmpty($primes) -> false
$list.contains($primes, 7) -> true
Example toolbox.xml config (if you want to use this with VelocityView):
<tool>
<key>list</key>
<scope>application</scope>
<class>org.apache.velocity.tools.generic.ListTool</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 version: $Id: $ since: VelocityTools 1.2 |