Hi Laurent,
Laurent Perez wrote on Friday, August 31, 2007 1:08 PM:
> Hi !
>
> Not sure if this is a bug or intended behaviour, given the following
> code :
>
> Transformer t = TransformerUtils.invokerTransformer("toLowerCase");
> List<String> abc = new ArrayList<String>();
> abc.add("A");
> List<String> tabc = ListUtils.transformedList(abc, t);
> System.out.println("tabc:" + tabc);
>
> This will return : tabc:[A] instead of tabc:[a].
>
> A single transform works, String a = (String)t.transform("A"); will
> return a lowercase "a".
>
> Is it a bug ?
It's defined behaviour. A transformer will only transformed new elements, not
the ones already available in the collection. This is, because the
TransformedList is a decorator for the original. See
http://commons.apache.org/collections/api-release/org/apache/commons/collections/list/TransformedList.html#TransformedList(java.util.List,%20org.apache.commons.collections.Transformer)
- Jörg
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]