Package org.jsoup.select
Class Collector
java.lang.Object
org.jsoup.select.Collector
public class Collector extends Object
Collects a list of elements that match the supplied criteria.
- Author:
- Jonathan Hedley
-
Method Summary
Modifier and TypeMethodDescriptionstatic Elements
Build a list of elements, by visiting the root and every descendant of root, and testing it against the Evaluator.collectNodes
(Evaluator evaluator, Element root, Class<T> type) Build a list of nodes that match the supplied criteria, by visiting the root and every descendant of root, and testing it against the Evaluator.static @Nullable Element
Finds the first Element that matches the Evaluator that descends from the root, and stops the query once that first match is found.static <T extends Node>
@Nullable TfindFirstNode
(Evaluator eval, Element root, Class<T> type) Finds the first Node that matches the Evaluator that descends from the root, and stops the query once that first match is found.static Stream
<Element> Obtain a Stream of elements by visiting the root and every descendant of root and testing it against the evaluator.static <T extends Node>
Stream<T> streamNodes
(Evaluator evaluator, Element root, Class<T> type) Obtain a Stream of nodes, of the specified type, by visiting the root and every descendant of root and testing it against the evaluator.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Method Details
-
collect
Build a list of elements, by visiting the root and every descendant of root, and testing it against the Evaluator.- Parameters:
-
eval
- Evaluator to test elements against -
root
- root of tree to descend - Returns:
- list of matches; empty if none
-
stream
Obtain a Stream of elements by visiting the root and every descendant of root and testing it against the evaluator.- Parameters:
-
evaluator
- Evaluator to test elements against -
root
- root of tree to descend - Returns:
-
A
Stream
of matches - Since:
- 1.19.1
-
streamNodes
public static <T extends Node> Stream<T> streamNodes(Evaluator evaluator, Element root, Class<T> type) Obtain a Stream of nodes, of the specified type, by visiting the root and every descendant of root and testing it against the evaluator. -
findFirst
Finds the first Element that matches the Evaluator that descends from the root, and stops the query once that first match is found.- Parameters:
-
eval
- Evaluator to test elements against -
root
- root of tree to descend - Returns:
-
the first match;
null
if none
-
findFirstNode
public static <T extends Node> @Nullable T findFirstNode(Evaluator eval, Element root, Class<T> type) Finds the first Node that matches the Evaluator that descends from the root, and stops the query once that first match is found. -
collectNodes
public static <T extends Node> Nodes<T> collectNodes(Evaluator evaluator, Element root, Class<T> type) Build a list of nodes that match the supplied criteria, by visiting the root and every descendant of root, and testing it against the Evaluator.
-