an iterator containing user objects). The problem seems to be when calling
CollectionsUtils.filter(...), I don't know the details of the CollectionUtils implementation
but the method seems to call some other behaviour than I expect.
My code works fine as long as I direct call my iterator() method everything is fine,
but using CollectionUtils something gets wrong.
Thx for any ideas Joerg
I can't see anything wrong with what you've sent, but I don't have the complete code. I suggest you break your task down into parts and check whether you really are converting the objects, or whether perhaps you are converting them at the wrong time in your logic.
Stephen
To: <[EMAIL PROTECTED]> Sent: Friday, December 10, 2004 6:05 PM Subject: Iterator problems collections
Hi folks,
I've got a problem with the CollecionUtils.filter method and the Iterator wrappers. I've written a custom Collections class which stores a tree data structure (based on DefaultMutableTreenode).
I want to hide the implementation (the usage of DefaultMutableTreeNode) and provided an iterator() methods which should return my user objects:
/** * Gets an iterator with all user objects */ public Iterator iterator() { Iterator it = new EnumerationIterator( root.breadthFirstEnumeration(),this); Iterator tranformedIt = IteratorUtils.transformedIterator(it, new TreeNodeToUserObjectTransformer()); return tranformedIt; }
/**
* Internal Transformer class for converting a TreeNode
* to it's user object
*/
private class TreeNodeToUserObjectTransformer implements Transformer {
public Object transform(Object o) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) o;
return node.getUserObject();
}
}
Now I'm calling CollectionUtils.filter(myCollection,myPredicate) and suspected to get my user objects passed to the removed(Object o) method. But instead of getting the userObjects, I get DefaultMutableTreeNOdes. Can anybody tell me what I'm doing wrong?
Thx Joerg
--------------------------------------------------------------------- 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]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
