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 Iterator
<JcrPath
> additionalPaths
;
15 private final Filter
<?
super Path
> filter
;
17 public NodeDirectoryStream(JcrFileSystem fs
, NodeIterator nodeIterator
, Iterator
<JcrPath
> additionalPaths
,
18 Filter
<?
super Path
> filter
) {
20 this.nodeIterator
= nodeIterator
;
21 this.additionalPaths
= additionalPaths
;
26 public void close() throws IOException
{
30 public Iterator
<Path
> iterator() {
31 return new Iterator
<Path
>() {
32 private JcrPath next
= null;
35 public synchronized boolean hasNext() {
38 nodes
: while (nodeIterator
.hasNext()) {
40 Node node
= nodeIterator
.nextNode();
41 String nodeName
= node
.getName();
42 if (nodeName
.startsWith("rep:") || nodeName
.startsWith("jcr:"))
44 if (fs
.skipNode(node
))
46 next
= new JcrPath(fs
, node
);
48 if (filter
.accept(next
))
52 } catch (Exception e
) {
53 throw new JcrFsException("Could not get next path", e
);
58 if (additionalPaths
.hasNext())
59 next
= additionalPaths
.next();
66 public synchronized Path
next() {
67 if (!hasNext())// make sure has next has been called