You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "Jukka Zitting (JIRA)" <ji...@apache.org> on 2008/01/02 19:18:34 UTC

[jira] Commented: (JCR-1259) Utility code for filtering and packaging trees

    [ https://issues.apache.org/jira/browse/JCR-1259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12555356#action_12555356 ] 

Jukka Zitting commented on JCR-1259:
------------------------------------

Looks good, though I have some design comments:

1) ItemFilter vs. Predicate

How about using the Predicate interface from commons-collections instead of the custom ItemFilter interface? Using Predicate would give us things like ItemFilterList, MatchAllFilter, MatchNoneFilter, and much more for free as well as working nicely together with our existing Iterator adapters in o.a.j.commons.iterator.

For example, with Predicate filters you could do something like this to select all child nodes with the given node type:

    NodeIterator iterator = new NodeIteratorAdapter(
        new FilterIterator(node.getNodes(), new NodeTypePredicate("my:type")));

Of course you'd need to use instanceof and type casts, but you'd need them in any case with ItemFilter as the interface takes Items, not Nodes or Properties. Also, you wouldn't have the "depth" parameter, but I'm not sure it's really needed (i.e. all the use cases I can think of could be solved with Item.getDepth()).

2) TreeWalkerListener vs. ItemVisitor

The JCR API already provides a nice implementation of the Visitor pattern in the ItemVisitor interface and the Item.accept(ItemVisitor) method. Instead of coming up with an alternative implementation in TreeWalker and TreeWalkerListener, I'd rather see a set of generic ItemVisitor classes like DepthFirstItemVisitor, DepthLimitedItemVisitor, BreadthFirstItemVisitor, FilterItemVisitor, etc. that could be combined together with each other and the above Predicate filters to implement functionality like in the proposed TreeWalker and in many other tree traversal cases.


> Utility code for filtering and packaging trees
> ----------------------------------------------
>
>                 Key: JCR-1259
>                 URL: https://issues.apache.org/jira/browse/JCR-1259
>             Project: Jackrabbit
>          Issue Type: New Feature
>          Components: jackrabbit-jcr-commons
>            Reporter: Carsten Ziegeler
>         Attachments: jcr-commons-filtering.zip
>
>
> The attached zip contains new utility code for filtering and packaging trees in the repository.
> A tree can be traversed by the provided tree walker. During the traversal configurable filters can be applied. The filters have influence on the traversal, like skipping nodes or properties.
> Included filters test the node name, node type etc. Custom filters are possible as well.
> A tree walker notifies a tree walker listener (interface) whenever it traverses an item.
> The second utility code is able to package a whole tree (through a description) and export this in some way - the exporter is an interface and could e.g. be an exporter serializing the tree into a zip archiv etc.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.