Class PathParentIterator

java.lang.Object
org.apache.zookeeper.server.watch.PathParentIterator
All Implemented Interfaces:
Iterator<String>

public class PathParentIterator extends Object implements Iterator<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 Details

    • forAll

      public static PathParentIterator forAll(String path)
      Return a new PathParentIterator that iterates from the given path to all parents.
      Parameters:
      path - initial path
    • forPathOnly

      public static PathParentIterator forPathOnly(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 Iterable<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 interface Iterator<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 String next()
      Specified by:
      next in interface Iterator<String>
    • remove

      public void remove()
      Specified by:
      remove in interface Iterator<String>