PathParentIterator (Apache ZooKeeper - Server 3.7.0 API)
Date: 2021-03-17

org.apache.zookeeper.server.watch

## 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 Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Iterable<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 constructor
    `static PathParentIterator` | `forAll(String path)` Return a new PathParentIterator that iterates from the given path to all parents.
    `static PathParentIterator` | `forPathOnly(String path)` Return a new PathParentIterator that only returns the given path - i.e.
    `boolean` | `hasNext()`
    `String` | `next()`
    `void` | `remove()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface java.util.Iterator

      `forEachRemaining`

- - ### Method Detail

    - #### 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>`

Copyright © 2008–2021 The Apache Software Foundation. All rights reserved.