|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.velocity.tools.generic.ListTool org.apache.velocity.tools.generic.ExtendedListTool
Tool for working with Lists and arrays in Velocity templates. In addition to the features ListTool provides, it provides the function to retrieve the length, and create clones of a list or an array object. Also provides a method to convert arrays into Lists and Lists into arrays.
Example uses: $primes -> new int[] {2, 3, 5, 7} $list.length($primes) -> 4 $list.get($primes, 2) -> 5 $list.clone($primes) -> int[] {2, 3, 5, 7}, != $primes $list.set($primes, 2, 1) -> (primes[2] becomes 1) $list.get($primes, 2) -> 1 $list.get($clone, 2) -> 5 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.ExtendedListTool</class> </tool>
This tool is entirely threadsafe, and has no instance members. It may be used in any scope (request, session, or application).
Constructor Summary | |
ExtendedListTool()
Default constructor. |
Method Summary | |
java.lang.Object |
clone(java.lang.Object list)
Gets the clone of a List/array. |
java.lang.Integer |
length(java.lang.Object array)
Gets the length of an array/List. |
java.lang.Object |
toArray(java.lang.Object list)
Converts a List object into an array. |
java.util.List |
toList(java.lang.Object array)
Converts an array object into a List. |
Methods inherited from class org.apache.velocity.tools.generic.ListTool |
contains, get, isArray, isEmpty, isList, set, size |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ExtendedListTool()
Method Detail |
public java.util.List toList(java.lang.Object array)
array
- an array object.
public java.lang.Object toArray(java.lang.Object list)
toArray()
method.
list
- a List object.
public java.lang.Integer length(java.lang.Object array)
array
is null.array
is not an array/List.ListTool.size(Object)
method.
array
- the array object.
ListTool.size(Object)
public java.lang.Object clone(java.lang.Object list)
list
is null.list
is not a List/array.
list
- the List/array object.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |