The problem is that the collections you pass in (dates) is supposed to be decorated. In order to transform the entries on construction there would need to be some way to alter the values already in dates, but the Collection interface provides no such direct mechanism.

However, it could be done indirectly:
a) Copy input collection to a list
b) Clear input collection
c) Transform each element from the list back into the original collection

If you would like to provide a patch (or just change SVN) to add a new static method (decorateTransform?) for doing this on TransformedCollection then please go ahead. (A new method is needed as the javadoc on the existing decorate method is explicit)

Note, that if you do do this then the new method should be added to all the Transformed* classes.

Stephen


Rob Oxspring wrote:
Hi,

I've just been burnt (and not for the first time) by the fact that the TransformedCollection doesn't transform the objects that are already in the wrapped collection. For example:

Collection dates = ... // a collection with Date objects in it
Transformer toString = ... // a transformer that calls toString
Collection strings =
    CollectionUtils.transformedCollection(dates,toString);

My intuition tells me that strings should be full of String objects and have no Date objects in it but the opposite is true. Is this the intended behaviour or is this a bug? I'm happy to patch the TransformedCollection class but wanted to run it passed people first...

Thanks,

Rob

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



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



Reply via email to