Date: 2004-10-14T18:47:46 Editor: ShinobuKawai <[EMAIL PROTECTED]> Wiki: Jakarta-Velocity Wiki Page: ArrayTool URL: http://wiki.apache.org/jakarta-velocity/ArrayTool
Javadoc Change Log: ------------------------------------------------------------------------------ @@ -35,9 +35,7 @@ * * <p>This tool is entirely threadsafe, and has no instance members. * It may be used in any scope (request, session, or application). - * As such, the methods are highly interconnected, and overriding - * key methods provides an easy way to create subclasses that use - * a non-default format or locale.</p> + * </p> * * @author <a href="mailto:[EMAIL PROTECTED]">Shinobu Kawai</a> * @version $Id: $ @@ -52,6 +50,27 @@ { } + /** + * Converts an array object into a List. + * <ul> + * <li> + * If the object is a List, it will return the List itself. + * </li> + * <li> + * If the object is an array of an Object, + * it will return a List of the elements. + * </li> + * <li> + * If the object is an array of a primitive type, + * it will return a List of the elements wrapped in their wrapper class. + * </li> + * <li> + * If the object is none of the above, it will return null. + * </li> + * </ul> + * @param array an array object. + * @return the converted List. + */ public List list(Object array) { if (array instanceof List) @@ -146,6 +165,18 @@ return null; } + /** + * Gets the specified element of an array. + * It will return null under the following conditions: + * <ul> + * <li><code>array</code> is null.</li> + * <li><code>array</code> is neither an array nor a List.</li> + * <li><code>array</code> doesn't have an <code>index</code>th value.</li> + * </ul> + * @param array the array object. + * @param index the index of the element to get. + * @return the specified element of an array. + */ public Object get(Object array, int index) { try @@ -158,6 +189,16 @@ return null; } + /** + * Gets the length of an array. + * It will return null under the following conditions: + * <ul> + * <li><code>array</code> is null.</li> + * <li><code>array</code> is neither an array nor a List.</li> + * </ul> + * @param array the array object. + * @return the length of an array. + */ public Integer length(Object array) { try --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
