|
|||||||||
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
@Deprecated @DefaultKey(value="lists") public class ListTool
Tool for working with Lists and arrays in Velocity templates.
With the release of Velocity 1.6, this class is largely obsolete since Velocity 1.6 now allows all List methods to be called on arrays within templates.
It provides a method to get and set specified elements. Also provides methods to perform the following actions to Lists and arrays:
Example uses: $primes -> new int[] {2, 3, 5, 7} $lists.size($primes) -> 4 $lists.get($primes, 2) -> 5 $lists.set($primes, 2, 1) -> (primes[2] becomes 1) $lists.get($primes, 2) -> 1 $lists.isEmpty($primes) -> false $lists.contains($primes, 7) -> true Example tools.xml config (if you want to use this with VelocityView): <tools> <toolbox scope="application"> <tool class="org.apache.velocity.tools.generic.ListTool"/> </toolbox> </tools>
This tool is entirely threadsafe, and has no instance members. It may be used in any scope (request, session, or application).
Constructor Summary | |
---|---|
ListTool()
Deprecated. |
Method Summary | |
---|---|
private java.lang.Boolean |
arrayContains(java.lang.Object array,
java.lang.Object element)
Deprecated. Checks if an array contains a certain element. |
java.lang.Boolean |
contains(java.lang.Object list,
java.lang.Object element)
Deprecated. Checks if a List/array contains a certain element. |
private boolean |
equals(java.lang.Object what,
java.lang.Object with)
Deprecated. Check if two objects are equal. |
java.lang.Object |
get(java.lang.Object list,
int index)
Deprecated. Gets the specified element of a List/array. |
private java.lang.Object |
getFromArray(java.lang.Object array,
int index)
Deprecated. Gets the specified element of an array. |
boolean |
isArray(java.lang.Object object)
Deprecated. Checks if an object is an array. |
java.lang.Boolean |
isEmpty(java.lang.Object list)
Deprecated. Checks if a List/array is empty. |
boolean |
isList(java.lang.Object object)
Deprecated. Checks if an object is a List. |
java.lang.Object |
set(java.lang.Object list,
int index,
java.lang.Object value)
Deprecated. Sets the specified element of a List/array. |
private java.lang.Object |
setToArray(java.lang.Object array,
int index,
java.lang.Object value)
Deprecated. Sets the specified element of an array. |
java.lang.Integer |
size(java.lang.Object list)
Deprecated. Gets the size of a List/array. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ListTool()
Method Detail |
---|
public java.lang.Object get(java.lang.Object list, int index)
list
is null.list
is not a List/array.list
doesn't have an index
th value.
list
- the List/array object.index
- the index of the List/array to get.
private java.lang.Object getFromArray(java.lang.Object array, int index)
array
- the array object.index
- the index of the array to get.
public java.lang.Object set(java.lang.Object list, int index, java.lang.Object value)
list
is null.list
is not a List/array.list
doesn't have an index
th value.
list
- the List/array object.index
- the index of the List/array to set.value
- the element to set.
private java.lang.Object setToArray(java.lang.Object array, int index, java.lang.Object value)
array
- the array object.index
- the index of the array to set.value
- the element to set.
public java.lang.Integer size(java.lang.Object list)
list
is null.list
is not a List/array.
list
- the List object.
public boolean isArray(java.lang.Object object)
object
- the object to check.
true
if the object is an array.public boolean isList(java.lang.Object object)
object
- the object to check.
true
if the object is a List.public java.lang.Boolean isEmpty(java.lang.Object list)
list
- the List/array to check.
true
if the List/array is empty.public java.lang.Boolean contains(java.lang.Object list, java.lang.Object element)
list
- the List/array to check.element
- the element to check.
true
if the List/array contains the element.private java.lang.Boolean arrayContains(java.lang.Object array, java.lang.Object element)
array
- the array to check.element
- the element to check.
true
if the array contains the element.private boolean equals(java.lang.Object what, java.lang.Object with)
what
- an objectwith
- another object.
true
if the two objects are equal.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |