velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christofer 'boz' Jennings <...@cox.net>
Subject Re: reading an array's length?
Date Sat, 19 Mar 2005 01:44:15 GMT
Ahh. Now I get tools.... So simple :-)

Dummied the ArrayTool down to just what I need. Later it can be swapped 
for the real thing I guess. Herre's what I did....

//----------------------------- start snip
package mystuff;

import java.lang.reflect.Array;

public class VelocityArrayTool
{

     /**
      * Default constructor.
      */
     public VelocityArrayTool()
     {
     }

     public Integer length(Object array)
     {
     		int length;
     		try {
     			length = Array.getLength(array);
     		}
     		catch (Exception e) {
     			return null;
     		}

         return new Integer(length);
     }

}
//----------------------------- end snip

then added it to the context as you suggested.

Thanks for all the help!

,boz

On Mar 18, 2005, at 8:07 AM, Mike Kienenberger wrote:

> Christofer 'boz' Jennings <boz@cox.net> wrote:
>> Is there a binary for ArrayTool somewhere or do I just build it?
>>
>> And how would it get configured programmatically (eg.
>> velocity.setProperty())?
>
> It's included with the latest (cvs) Velocity tools, I think.
>
> It's also available on the Velocity Wiki.
>
> http://wiki.apache.org/jakarta-velocity/ArrayTool
>
> It's easy enough to just add it to your project as another java file 
> (that's
> what I'd do).
>
> To use it, either configure it via toolbox.xml (if you're using that) 
> or
> just do a velocityContext.put("arrayTool", new ArrayTool());
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message