commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jörg Herbst <>
Subject Iterator problems collections
Date Fri, 10 Dec 2004 18:05:20 GMT
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(
        Iterator tranformedIt =
                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?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message