Class PathParentIterator
- java.lang.Object
-
- org.apache.zookeeper.server.watch.PathParentIterator
-
- All Implemented Interfaces:
java.util.Iterator<java.lang.String>
public class PathParentIterator extends java.lang.Object implements java.util.Iterator<java.lang.String>
Iterates over a ZooKeeper path. Each iteration goes up one parent path. Thus, the effect of the iterator is to iterate over the initial path and then all of its parents.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Iterable<java.lang.String>
asIterable()
Return an Iterable view so that this Iterator can be used in for each statements.boolean
atParentPath()
Returns true if this iterator is currently at a parent path as opposed to the initial path given to the constructorstatic PathParentIterator
forAll(java.lang.String path)
Return a new PathParentIterator that iterates from the given path to all parents.static PathParentIterator
forPathOnly(java.lang.String path)
Return a new PathParentIterator that only returns the given path - i.e.boolean
hasNext()
java.lang.String
next()
void
remove()
-
-
-
Method Detail
-
forAll
public static PathParentIterator forAll(java.lang.String path)
Return a new PathParentIterator that iterates from the given path to all parents.- Parameters:
path
- initial path
-
forPathOnly
public static PathParentIterator forPathOnly(java.lang.String path)
Return a new PathParentIterator that only returns the given path - i.e. does not iterate to parent paths.- Parameters:
path
- initial path
-
asIterable
public java.lang.Iterable<java.lang.String> asIterable()
Return an Iterable view so that this Iterator can be used in for each statements. IMPORTANT: the returned Iterable is single use only- Returns:
- Iterable
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfacejava.util.Iterator<java.lang.String>
-
atParentPath
public boolean atParentPath()
Returns true if this iterator is currently at a parent path as opposed to the initial path given to the constructor- Returns:
- true/false
-
next
public java.lang.String next()
- Specified by:
next
in interfacejava.util.Iterator<java.lang.String>
-
remove
public void remove()
- Specified by:
remove
in interfacejava.util.Iterator<java.lang.String>
-
-