opensubscriber
   Find in this group all groups
 
Unknown more information…

v : velocity-user@jakarta.apache.org 10 November 2006 • 11:36PM -0500

Re: How to get Type of variable
by Paul Loy

REPLY TO AUTHOR
 
REPLY TO GROUP




Try doing a .class?

#foreach($item in $arrayList)
    #set($classType = $item.class)

    #if ($classType == "com.domain.classname")
        do something
    #else
        don't do it!
    #end
#end

(this code isn't tested... just in my head!)

rjain wrote:
> I have a ArrayList which can contain either items of TypeA or TypeB
>
> #foreach($item in $arrayList)
>   #if ($item <isoftype> TypeA)
>          Do something
>   #else ($item <isoftype> TypeB)
>          Do something else
>   #end
> #end
>
> How do I get the Type of Item in the Arraylist?
>
> Thanks!!
>  


--

*Paul Loy
Software Developer*

Peoples Archive Ltd.
Middlesex House
34-42 Cleveland Street
London, W1T 4LB

Tel: +44 (0) 20 7323 0323
Fax: +44 (0) 20 7580 1938
paul.loy@peop...


Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.