How can I iterate a collection and modify at the same time ?
Example
public static Collection getAncestors(
Entity aEntity, Object aContext ){
Collection vAncestors=new ArrayList();
IDocument vDocument= findDocumentByName(
aEntity.getSuper(), aContext);
vAncestors.add(vDocument);
for(
Iterator i=vAncestors.iterator();
i.hasNext();
){
getAncestors(vAncestors,
(IDocument)i.next(), aContext);
}
return vAncestors;
}
public static void getAncestors(
Collection aAncestors,
IDocument aDocument ,
Object aContext){
Entity vEntity=(Entity)aDocument.get();
if(vEntity.getSuper()!=null){
IDocument vDocument= findDocumentByName(
vEntity.getSuper(),
aContext);
aAncestors.add(vDocument);
}
}
Thanks
Miro
---------------------------------
Sucker-punch spam with award-winning protection.
Try the free Yahoo! Mail Beta.