Class NodeListIterator

  • All Implemented Interfaces:
    java.util.Iterator<org.w3c.dom.Node>

    public class NodeListIterator
    extends AbstractNodeIterator<org.w3c.dom.Node>
    Iterates through the nodes in a NodeList. The original node list must not be modified externally during iteration.
    Author:
    Garret Wilson
    Implementation Specification:
    This implementation fails fast, throwing a ConcurrentModificationException if it determines on a best-effort basis that the original node list has been modified.
    See Also:
    NodeList
    • Constructor Summary

      Constructors 
      Constructor Description
      NodeListIterator​(org.w3c.dom.NodeList nodeList)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected int getLength()  
      protected org.w3c.dom.Node getNode​(int index)
      Retrieves the node at the given index from the underlying data structure.
      protected void removeImpl​(org.w3c.dom.Node node)
      Implementation that actually removes the node from the underlying data structure.
      • 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
    • Constructor Detail

      • NodeListIterator

        public NodeListIterator​(@Nonnull
                                org.w3c.dom.NodeList nodeList)
        Constructor.
        Parameters:
        nodeList - The node list to iterate through.
    • Method Detail

      • getLength

        protected int getLength()
        Specified by:
        getLength in class AbstractNodeIterator<org.w3c.dom.Node>
        Returns:
        The current length of the underlying data structure.
      • getNode

        protected org.w3c.dom.Node getNode​(int index)
        Description copied from class: AbstractNodeIterator
        Retrieves the node at the given index from the underlying data structure.
        Specified by:
        getNode in class AbstractNodeIterator<org.w3c.dom.Node>
        Parameters:
        index - The index of the node to retrieve.
        Returns:
        The node at the given index, or null if the index is not valid.
      • removeImpl

        protected void removeImpl​(org.w3c.dom.Node node)
        Implementation that actually removes the node from the underlying data structure.

        This method must not change any iterator state variables.

        Overrides:
        removeImpl in class AbstractNodeIterator<org.w3c.dom.Node>
        Implementation Specification:
        This implementation removes the attribute node by calling Node.removeChild(Node) on the node's parent node.
        Parameters:
        node - The node to remove.
        See Also:
        Node.removeChild(Node)