velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Will Glass-Husain <wgl...@forio.com>
Subject Re: How can I get the length of Array ?
Date Thu, 25 May 2006 15:26:38 GMT
That'll teach me to read the question fully before answering...

#set($abc = [1,2,3])

actually creates an ArrayList, so any List method-- such as size()-- 
will work.

WILL

Townson, Chris wrote:
> How do you mean, Will?
>
> $myArray.class.name returns java.util.ArrayList and $myArray.size() has always worked
for me.
>
> Chris 
>
>   
>> -----Original Message-----
>> From: Will Glass-Husain [mailto:wglass@forio.com] 
>> Sent: 25 May 2006 14:50
>> To: Velocity Users List
>> Subject: Re: How can I get the length of Array ?
>>
>> Not true, though it's on our feature request list.
>>
>> Use ListTool from the Velocity tools project.
>>
>> WILL
>>
>> Withers John Z wrote:
>>     
>>> I think $arr.size() would return the length of the array.  If memory
>>> serves, Velocity implements arrays as ArrayList.
>>>
>>> John Withers 
>>>
>>> -----Original Message-----
>>> From: trad-ex [mailto:trad-ex@inter7.jp] 
>>> Sent: Thursday, May 25, 2006 1:13 AM
>>> To: Velocity Users List
>>> Subject: How can I get the length of Array ?
>>>
>>> Hi all,
>>>
>>> In the Velocity realm, how can I get the length of Array ?
>>> For instance,
>>>
>>> #set( $arr = __set int[] value__ )
>>> #if( $arr.length > 0 )
>>>  ...(snip)...
>>>  
>>> $arr.length is always null. Why ?
>>> I always use helper Object to avoid this issue.
>>> For example, 
>>>
>>> $helperObj.lengthOf( $arr )
>>>
>>> This method, lengthOf, is described below:
>>>
>>>  public int lengthOf( Object[] objects )  {
>>>    if( objects == null)
>>>      return 0;
>>>    return objects.length;
>>>  }
>>>  
>>> Best Regards,
>>> trad-ex
>>>
>>>
>>>
>>>       
>> ---------------------------------------------------------------------
>>     
>>> 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
>>     
>>>   
>>>       
>> -- 
>> Forio Business Simulations
>>
>> Will Glass-Husain
>> phone (415) 440-7500 x89
>> mobile (415) 235-4293
>> wglass@forio.com
>> www.forio.com
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>
>>     
>
> ********************************************************************************   
> DISCLAIMER: This e-mail is confidential and should not be used by anyone who is
> not the original intended recipient. If you have received this e-mail in error
> please inform the sender and delete it from your mailbox or any other storage
> mechanism. Neither Macmillan Publishers Limited nor any of its agents accept
> liability for any statements made which are clearly the sender's own and not
> expressly made on behalf of Macmillan Publishers Limited or one of its agents.
> Please note that neither Macmillan Publishers Limited nor any of its agents
> accept any responsibility for viruses that may be contained in this e-mail or
> its attachments and it is your responsibility to scan the e-mail and 
> attachments (if any). No contracts may be concluded on behalf of Macmillan 
> Publishers Limited or its agents by means of e-mail communication. Macmillan 
> Publishers Limited Registered in England and Wales with registered number 785998 
> Registered Office Brunel Road, Houndmills, Basingstoke RG21 6XS   
> ********************************************************************************
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
>   

-- 
Forio Business Simulations

Will Glass-Husain
phone (415) 440-7500 x89
mobile (415) 235-4293
wglass@forio.com
www.forio.com


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message