Subject: Tranforming Collection to a Map
From: "Lance" <[EMAIL PROTECTED]>
 ===
Is there a method somewhere hidden in the commons package for doing this.  I
see the CollectionUtils.getCardinalityMap(Collection col) method, but it's
not what I'm really looking for.  I wanna do something like this:

Collection roles = new ArrayList();
//populate list
Transformer tranformer = new RoleMapTransformer();

Map map = CollectionUtils.getMap(roles, transformer);

//My Transform class
class RoleMapTransformer implements
org.apache.commons.collections.Transformer
{
    public Object transform(Object obj)
    {
         RoleData role = (RoleData)obj;

         return new DefaultMapEntry(role.getRoleID(), role.getName());
    }
 }

Maybe org.apache.commons.collections.BeanMap does this.  There's just not
enough info in javadocs

Using Struts nightly build

Thanks in Advance...

--
Lance



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to