Top Description Fields Constructors Methods
org.apache.commons.collections4.iterators

public Class NodeListIterator

extends Object
implements Iterator<Node>
Class Inheritance
All Implemented Interfaces
java.util.Iterator
Imports
java.util.Iterator, .NoSuchElementException, org.w3c.dom.Node, .NodeList

An Iterator over a NodeList.

This iterator does not support remove() as a NodeList does not support removal of items.

Since
4.0
See Also
NodeList

Field Summary

Modifier and TypeField and Description
private int
index

The current iterator index

private final NodeList
nodeList

the original NodeList instance

Constructor Summary

AccessConstructor and Description
public
NodeListIterator(final Node
Node, who's child nodes are wrapped by this class. Must not be null
node
)

Convenience constructor, which creates a new NodeListIterator from the specified node's childNodes.

public
NodeListIterator(final NodeList
node list, which is wrapped by this class. Must not be null
nodeList
)

Constructor, that creates a new NodeListIterator from the specified org.w3c.NodeList

Method Summary

Modifier and TypeMethod and Description
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.
public Node
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

indexback to summary
private int index

The current iterator index

nodeListback to summary
private final NodeList nodeList

the original NodeList instance

Constructor Detail

NodeListIteratorback to summary
public NodeListIterator(final Node node)

Convenience constructor, which creates a new NodeListIterator from the specified node's childNodes.

Parameters
node:Node

Node, who's child nodes are wrapped by this class. Must not be null

Exceptions
NullPointerException:
if node is null
NodeListIteratorback to summary
public NodeListIterator(final NodeList nodeList)

Constructor, that creates a new NodeListIterator from the specified org.w3c.NodeList

Parameters
nodeList:NodeList

node list, which is wrapped by this class. Must not be null

Exceptions
NullPointerException:
if nodeList is null

Method Detail

hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
nextback to summary
public Node next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:Node

the next element in the iteration

Annotations
@Override
removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Throws UnsupportedOperationException.

Annotations
@Override
Exceptions
UnsupportedOperationException:
always