All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.sirix.axis.pathsummary.ChildAxis Maven / Gradle / Ivy

package io.sirix.axis.pathsummary;

import io.sirix.index.path.summary.PathNode;

/**
 * Iterate over all children starting at a given node. Self is not included.
 *
 * @author Johannes Lichtenberger
 */
public final class ChildAxis extends AbstractAxis {

  /**
   * Has another child node.
   */
  private boolean first;

  /**
   * Constructor initializing internal state.
   *
   * @param pathNode context node
   */
  public ChildAxis(final PathNode pathNode) {
    super(pathNode);
    first = true;
  }

  @Override
  public void reset(PathNode pathNode) {
    first = true;
    super.reset(pathNode);
  }

  @Override
  protected PathNode nextNode() {
    if (!first && nextNode.hasRightSibling()) {
      return nextNode.getRightSibling();
    } else if (first && nextNode.hasFirstChild()) {
      first = false;
      return nextNode.getFirstChild();
    }

    return done();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy