You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Michael <sg...@gmx.net> on 2008/12/15 21:47:45 UTC

[Collections] Transforming Maps and Lists

Hi folks,

I'd like to transform both.
E.g. adding strings to a list and let the transformer lowercase them. 
Unfortunately the ListUtils#tranformedList(List, Transformer) 
transformer only when I add elements.

Is there a way to achieve one-time tranformation?

Thanks,

Mike

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


Re: [Collections] Transforming Maps and Lists

Posted by James Carman <ja...@carmanconsulting.com>.
I would always check CollectionUtils first.

On Mon, Dec 15, 2008 at 4:56 PM, Michael <sg...@gmx.net> wrote:
> Michael wrote:
>>
>> James Carman wrote:
>>>
>>> Have you tried this?
>>>
>>>
>>> http://commons.apache.org/collections/api-release/org/apache/commons/collections/CollectionUtils.html#transform(java.util.Collection,%20org.apache.commons.collections.Transformer)
>>
>> No,
>>
>> I tried
>> http://commons.apache.org/collections/api-release/org/apache/commons/collections/ListUtils.html#transformedList(java.util.List,%20org.apache.commons.collections.Transformer)
>>
>> beause it seems the best thing which it isn't :-(
>
> EDIT: Your proposed method does!
>
> Unfortunately the Util classed and collection/map classes are not really
> done uniformly :-(
> I have to transform a list of maps which contain oracle.sql.TIMESTAMP but
> has to be java.sql.Timestamp since oracle's timestamp is useless in JSP and
> DisplayTag (fmt, comparable).
>
> Thanks
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

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


Re: [Collections] Transforming Maps and Lists

Posted by Michael <sg...@gmx.net>.
Michael wrote:
> James Carman wrote:
>> Have you tried this?
>>
>> http://commons.apache.org/collections/api-release/org/apache/commons/collections/CollectionUtils.html#transform(java.util.Collection,%20org.apache.commons.collections.Transformer) 
>>
> 
> No,
> 
> I tried 
> http://commons.apache.org/collections/api-release/org/apache/commons/collections/ListUtils.html#transformedList(java.util.List,%20org.apache.commons.collections.Transformer) 
> 
> 
> beause it seems the best thing which it isn't :-(

EDIT: Your proposed method does!

Unfortunately the Util classed and collection/map classes are not really 
done uniformly :-(
I have to transform a list of maps which contain oracle.sql.TIMESTAMP 
but has to be java.sql.Timestamp since oracle's timestamp is useless in 
JSP and DisplayTag (fmt, comparable).

Thanks

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


Re: [Collections] Transforming Maps and Lists

Posted by Michael <sg...@gmx.net>.
James Carman wrote:
> Have you tried this?
> 
> http://commons.apache.org/collections/api-release/org/apache/commons/collections/CollectionUtils.html#transform(java.util.Collection,%20org.apache.commons.collections.Transformer)

No,

I tried 
http://commons.apache.org/collections/api-release/org/apache/commons/collections/ListUtils.html#transformedList(java.util.List,%20org.apache.commons.collections.Transformer)

beause it seems the best thing which it isn't :-(

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


Re: [Collections] Transforming Maps and Lists

Posted by James Carman <ja...@carmanconsulting.com>.
Have you tried this?

http://commons.apache.org/collections/api-release/org/apache/commons/collections/CollectionUtils.html#transform(java.util.Collection,%20org.apache.commons.collections.Transformer)

On Mon, Dec 15, 2008 at 3:47 PM, Michael <sg...@gmx.net> wrote:
> Hi folks,
>
> I'd like to transform both.
> E.g. adding strings to a list and let the transformer lowercase them.
> Unfortunately the ListUtils#tranformedList(List, Transformer) transformer
> only when I add elements.
>
> Is there a way to achieve one-time tranformation?
>
> Thanks,
>
> Mike
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

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