jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lukas Eder (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (JCR-3555) Add a static utility to transform JCR Iterators into Iterables
Date Wed, 03 Apr 2013 09:03:15 GMT

     [ https://issues.apache.org/jira/browse/JCR-3555?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

Lukas Eder updated JCR-3555:

    Attachment: JcrUtils.java.patch

Attached a patch (JcrUtils.java.patch) containing:

- Removal of previously added Iterators class
- Addition of JcrUtils.in(...) methods (from Iterators)
- Throw an IllegalStateException if such an Iterable is used twice
- Documented this behaviour in JcrUtils.in(...) Javadocs
- Deprecated NodeIterable, PropertyIterable, RowIterable with link to new methods (feel free
to exclude that change)
- Added test case for IllegalStateException

The Stack Overflow question had an interesting answer linking to java.nio.file.DirectoryStream,
which implements a "one shot" Iterable with a bold warning in the Javadoc. See the answer

I'm actually a bit reluctant to introduce a new type. We might regret such a type in the future,
should we want to enhance the "in(...)" methods to return caching, reusable Iterables.
> Add a static utility to transform JCR Iterators into Iterables
> --------------------------------------------------------------
>                 Key: JCR-3555
>                 URL: https://issues.apache.org/jira/browse/JCR-3555
>             Project: Jackrabbit Content Repository
>          Issue Type: Improvement
>          Components: jackrabbit-jcr-commons
>    Affects Versions: 2.6
>            Reporter: Lukas Eder
>            Priority: Minor
>         Attachments: Iterators.java.patch, JcrUtils.java.patch
> I have stumbled upon the utility classes in the org.apache.jackrabbit.commons.iterator
package. They're quite useful in principle, but not applied thoroughly. E.g. there are missing
wrapper types for at least these JCR Iterators:
> - AccessControlPolicyIterator
> - EventIterator
> - EventListenerIterator
> - NodeTypeIterator
> - VersionIterator
> Instead of adding more classes, it might be useful to create static methods for the job.
Using static methods from a single class (with static imports) is a bit more convenient than
looking up and creating the wrapper types using "new WrapperType(...)"
> An example:
> org.apache.jackrabbit.commons.iterator.Iterators.iterable
> // And then:
> for (Node n : iterable(parent.getNodes())) {
>   // Do stuff with n
> }
> Please find attached a .patch file containing an implementation suggestion.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

View raw message