Details
-
New Feature
-
Resolution: Outdated
-
Trivial
-
None
-
3.5.4
-
None
-
java 1.4 syntax
-
-
Empty show more show less
Description
A simple ContentFilter built to satisfy the following use case:
When building a simpleNavigation, I wanted to only show the parent page of a certain node, and certain children that had a given property set. To retrieve a collection of these pages is trivial using a jcr:query.
Originally, I had it using the simple collection.contains(content) to determine if a page should be returned - but the way Content is implemented at this point doesn't lend itself to this kind of collection operation (it only does the "exact same memory address" comparisson at this point - and I'm not about to overload that for my simple content filter)
The filter will first attempt to use that simple operation, since it is cheap - and then it iterates over all of the items in the existing collection. If it finds a match, it returns true (accept)
If more collection-based filters are required, it would be trivial to abstract the content-based filtering approach and add callback methods for performing the functioning logic and to create simple specialized versions of the filter (such as only accept things that are not in the collection... etc )