You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Rafael U. C. Afonso" <r....@uol.com.br> on 2004/08/04 04:09:30 UTC
Tranformer collection processor
Hello:
Is there something in Collections that, given a collection
and a Transformer, return a collection of transformed
Objects?
It would be like this:
class TransformeProcessorCollection {
private Transformer transformer;
public TransformeProcessorCollection(Transformer trans) {
transformer = trans;
}
public Collection process(Colletcion col) {
Collection newCol = new ArrayList(col.size); // Or
some other type of Collection
Iterator it = new TransformIterator(col.iterator(),
transformer);
while(it.hasNext()) {
newCol.add(it.next());
}
return newCol;
}
}
If it does not exist, I would like suggest it for Commons
Collections. Something similar would be done with Closures
and Predicates.
Thanks,
Rafael Ubiratam Clemente Afonso
r.u.c.afonso@uol.com.br
---------------------------------
Where is Debug?
Debug is on the Table!
__________________________________________________________________________
Acabe com aquelas janelinhas que pulam na sua tela.
AntiPop-up UOL - É grátis!
http://antipopup.uol.com.br/
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: Tranformer collection processor
Posted by Kishore Senji <ks...@gmail.com>.
CollectionUtils.transform(Collection collection, Transformer
transformer); does what you have proposed
On Tue, 3 Aug 2004 23:09:30 -0300, Rafael U. C. Afonso
<r....@uol.com.br> wrote:
> Hello:
>
> Is there something in Collections that, given a collection
> and a Transformer, return a collection of transformed
> Objects?
> It would be like this:
>
> class TransformeProcessorCollection {
> private Transformer transformer;
>
> public TransformeProcessorCollection(Transformer trans) {
> transformer = trans;
> }
>
> public Collection process(Colletcion col) {
> Collection newCol = new ArrayList(col.size); // Or
> some other type of Collection
> Iterator it = new TransformIterator(col.iterator(),
> transformer);
> while(it.hasNext()) {
> newCol.add(it.next());
> }
> return newCol;
> }
>
> }
>
> If it does not exist, I would like suggest it for Commons
> Collections. Something similar would be done with Closures
> and Predicates.
>
> Thanks,
>
> Rafael Ubiratam Clemente Afonso
> r.u.c.afonso@uol.com.br
> ---------------------------------
> Where is Debug?
> Debug is on the Table!
>
> __________________________________________________________________________
> Acabe com aquelas janelinhas que pulam na sua tela.
> AntiPop-up UOL - É grátis!
> http://antipopup.uol.com.br/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org