1 package org
.argeo
.jcr
.fs
;
3 import java
.io
.IOException
;
4 import java
.nio
.file
.DirectoryStream
;
5 import java
.nio
.file
.Path
;
6 import java
.util
.Iterator
;
9 import javax
.jcr
.NodeIterator
;
11 public class NodeDirectoryStream
implements DirectoryStream
<Path
> {
12 private final JcrFileSystem fs
;
13 private final NodeIterator nodeIterator
;
14 private final Filter
<?
super Path
> filter
;
16 public NodeDirectoryStream(JcrFileSystem fs
, NodeIterator nodeIterator
, Filter
<?
super Path
> filter
) {
18 this.nodeIterator
= nodeIterator
;
23 public void close() throws IOException
{
27 public Iterator
<Path
> iterator() {
28 return new Iterator
<Path
>() {
29 private JcrPath next
= null;
32 public synchronized boolean hasNext() {
35 nodes
: while (nodeIterator
.hasNext()) {
37 Node node
= nodeIterator
.nextNode();
38 String nodeName
= node
.getName();
39 if (nodeName
.startsWith("rep:") || nodeName
.startsWith("jcr:"))
41 if (fs
.skipNode(node
))
43 next
= new JcrPath(fs
, node
);
45 if (filter
.accept(next
))
49 } catch (Exception e
) {
50 throw new JcrFsException("Could not get next path", e
);
57 public synchronized Path
next() {
58 if (!hasNext())// make sure has next has been called