Class ReverseDescendantIterator

java.lang.Object
com.puppycrawl.tools.checkstyle.xpath.iterators.ReverseDescendantIterator
All Implemented Interfaces:
Closeable, AutoCloseable, net.sf.saxon.om.SequenceIterator, net.sf.saxon.tree.iter.AxisIterator

public class ReverseDescendantIterator extends Object implements net.sf.saxon.tree.iter.AxisIterator
Recursive-free implementation of the descendant axis iterator. Difference between this iterator and DescendantIterator in traversal order of the child nodes. In some cases it is useful to iterate from last child backwards to the first one, for example in PrecedingIterator.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Queue<net.sf.saxon.om.NodeInfo>
    Queue for sibling nodes.
    private final Deque<net.sf.saxon.om.NodeInfo>
    Stack for child nodes, to represent them in reverse order.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ReverseDescendantIterator(net.sf.saxon.om.NodeInfo start)
    Create an iterator over the "descendant" axis in reverse order.
  • Method Summary

    Modifier and Type
    Method
    Description
    net.sf.saxon.om.NodeInfo
    Get the next item in the sequence.
    private void
    pushToStack(net.sf.saxon.tree.iter.AxisIterator iterateAxis)
    Pushes all children to the stack.

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface net.sf.saxon.om.SequenceIterator

    close
  • Field Details

    • queue

      private final Queue<net.sf.saxon.om.NodeInfo> queue
      Queue for sibling nodes.
    • stack

      private final Deque<net.sf.saxon.om.NodeInfo> stack
      Stack for child nodes, to represent them in reverse order.
  • Constructor Details

    • ReverseDescendantIterator

      public ReverseDescendantIterator(net.sf.saxon.om.NodeInfo start)
      Create an iterator over the "descendant" axis in reverse order.
      Parameters:
      start - the initial context node.
  • Method Details

    • pushToStack

      private void pushToStack(net.sf.saxon.tree.iter.AxisIterator iterateAxis)
      Pushes all children to the stack.
      Parameters:
      iterateAxis - AxisInfo.CHILD axis iterator.
    • next

      public net.sf.saxon.om.NodeInfo next()
      Get the next item in the sequence.
      Specified by:
      next in interface net.sf.saxon.tree.iter.AxisIterator
      Specified by:
      next in interface net.sf.saxon.om.SequenceIterator
      Returns:
      the next Item. If there are no more nodes, return null.