类 ListTool
java.lang.Object
org.apache.velocity.tools.generic.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:
- Check if it is empty.
- Check if it contains a certain element.
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).
- 从以下版本开始:
- VelocityTools 1.2
- 版本:
- $Id: $
- 作者:
- Shinobu Kawai
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明private Boolean
arrayContains
(Object array, Object element) 已过时。Checks if an array contains a certain element.已过时。Checks if a List/array contains a certain element.private boolean
已过时。Check if two objects are equal.已过时。Gets the specified element of a List/array.private Object
getFromArray
(Object array, int index) 已过时。Gets the specified element of an array.boolean
已过时。Checks if an object is an array.已过时。Checks if a List/array is empty.boolean
已过时。Checks if an object is a List.已过时。Sets the specified element of a List/array.private Object
setToArray
(Object array, int index, Object value) 已过时。Sets the specified element of an array.已过时。Gets the size of a List/array.
-
构造器详细资料
-
ListTool
public ListTool()已过时。
-
-
方法详细资料
-
get
已过时。Gets the specified element of a List/array. It will return null under the following conditions:list
is null.list
is not a List/array.list
doesn't have anindex
th value.
- 参数:
list
- the List/array object.index
- the index of the List/array to get.- 返回:
- the specified element of the List/array.
-
getFromArray
已过时。Gets the specified element of an array.- 参数:
array
- the array object.index
- the index of the array to get.- 返回:
- the specified element of the array.
-
set
已过时。Sets the specified element of a List/array. It will return null under the following conditions:list
is null.list
is not a List/array.list
doesn't have anindex
th value.
- 参数:
list
- the List/array object.index
- the index of the List/array to set.value
- the element to set.- 返回:
- blank if set, null if not set.
-
setToArray
已过时。Sets the specified element of an array.- 参数:
array
- the array object.index
- the index of the array to set.value
- the element to set.- 返回:
- blank if set, null if not set.
-
size
已过时。Gets the size of a List/array. It will return null under the following conditions:list
is null.list
is not a List/array.
- 参数:
list
- the List object.- 返回:
- the size of the List.
-
isArray
已过时。Checks if an object is an array.- 参数:
object
- the object to check.- 返回:
true
if the object is an array.
-
isList
已过时。Checks if an object is a List.- 参数:
object
- the object to check.- 返回:
true
if the object is a List.
-
isEmpty
已过时。Checks if a List/array is empty.- 参数:
list
- the List/array to check.- 返回:
true
if the List/array is empty.
-
contains
已过时。Checks if a List/array contains a certain element.- 参数:
list
- the List/array to check.element
- the element to check.- 返回:
true
if the List/array contains the element.
-
arrayContains
已过时。Checks if an array contains a certain element.- 参数:
array
- the array to check.element
- the element to check.- 返回:
true
if the array contains the element.
-
equals
已过时。Check if two objects are equal.- 参数:
what
- an objectwith
- another object.- 返回:
true
if the two objects are equal.
-