Package org.jsoup.nodes
Class NodeIterator<T extends Node>
java.lang.Object
org.jsoup.nodes.NodeIterator<T>
- All Implemented Interfaces:
Iterator<T>
Iterate through a Node and its tree of descendants, in document order, and returns nodes of the specified type. This
iterator supports structural changes to the tree during the traversal, such as
Node.remove()
,
Node.replaceWith(Node)
, Node.wrap(String)
, etc.
See also the NodeTraversor
if head
and tail
callbacks are
desired for each node.
- Since:
- 1.17.1
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionNodeIterator
(Node start, Class<T> type) Create a NoteIterator that will iterate the supplied node, and all of its descendants. -
Method Summary
Modifier and TypeMethodDescriptionprivate T
static NodeIterator
<Node> Create a NoteIterator that will iterate the supplied node, and all of its descendants.boolean
hasNext()
private void
If next is not null, looks for and sets next.next()
void
remove()
void
Restart this Iterator from the specified start node.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
-
Field Details
-
root
-
next
-
current
-
previous
-
currentParent
-
type
-
-
Constructor Details
-
NodeIterator
Create a NoteIterator that will iterate the supplied node, and all of its descendants. The returnednext
type will be filtered to the input type.- Parameters:
start
- initial nodetype
- node type to filter for
-
-
Method Details
-
from
Create a NoteIterator that will iterate the supplied node, and all of its descendants. All node types will be returned.- Parameters:
start
- initial node
-
restart
Restart this Iterator from the specified start node. Will act as if it were newly constructed. Useful for e.g. to save some GC if the iterator is used in a tight loop.- Parameters:
start
- the new start node.
-
hasNext
public boolean hasNext() -
next
-
maybeFindNext
private void maybeFindNext()If next is not null, looks for and sets next. If next is null after this, we have reached the end. -
findNextNode
-
remove
public void remove()
-