Interface NodeIterator
- All Superinterfaces:
Iterator<Node>
,ListIterator<Node>
Interoperability
This interface is based on the NodeIterator
interface in DOM Level 4, although behaviour does not exactly match:
Iterators implementing this interface are expected to skip full nodes
(descendants included) when the NodeFilter
returns
NodeFilter.FILTER_SKIP_NODE_CHILD
, while the W3C standard would
expect it to behave like NodeFilter.FILTER_SKIP
(which in this implementation is called NodeFilter.FILTER_SKIP_NODE
),
and skip only the node itself.
Additionally, beware that this iterator also behaves differently from the
Xerces NodeIterator
regarding attributes:
- Attributes do not always follow the specified order in Xerces.
- Its iterator of attributes only traverses the root node.
If the filtering done by the NodeFilter
changes during the
traversal (that is, nodes that were previously accepted now aren't), the
behaviour of this iterator may become inconsistent when going backwards. In
that case, you may want to try a TreeWalker
instead.
ListIterator
optional operations: add
,
set
, remove
This library's iterator implements ListIterator
and its optional
operations, but any attempts to remove
the root node, to change
it with set
(or to insert a node before it with
add
) must fail.
-
Method Summary
Modifier and TypeMethodDescriptionGet theNodeFilter
callback.getRoot()
The root node to iterate.int
The bitmask specifying what types of nodes to show.next()
nextNode()
The same asnext()
, but avoids theNoSuchElementException
.previous()
The same asprevious()
, but avoids theNoSuchElementException
.Methods inherited from interface java.util.Iterator
forEachRemaining
Methods inherited from interface java.util.ListIterator
add, hasNext, hasPrevious, nextIndex, previousIndex, remove, set
-
Method Details
-
getRoot
DOMNode getRoot()The root node to iterate.See the description of
root
in DOM Level 4.- Returns:
- the root node.
-
getWhatToShow
int getWhatToShow()The bitmask specifying what types of nodes to show.- Returns:
- the bitmask to control which types of nodes are returned by the iterator.
-
getNodeFilter
NodeFilter getNodeFilter()Get theNodeFilter
callback.See
NodeFilter
.- Returns:
- a reference to the
NodeFilter
callback.
-
next
DOMNode next() -
nextNode
DOMNode nextNode()The same asnext()
, but avoids theNoSuchElementException
. Exists for compatibility with theNodeIterator
in DOM Level 4.- Returns:
- the next node, or
null
if there is no next node.
-
previous
DOMNode previous()- Specified by:
previous
in interfaceListIterator<Node>
-
previousNode
DOMNode previousNode()The same asprevious()
, but avoids theNoSuchElementException
. Exists for compatibility with theNodeIterator
in DOM Level 4.- Returns:
- the previous node, or
null
if there is no previous node.
-