Package org.jsoup.select
Class Evaluator
java.lang.Object
org.jsoup.select.Evaluator
- Direct Known Subclasses:
CombiningEvaluator,Evaluator.AllElements,Evaluator.Attribute,Evaluator.AttributeKeyPair,Evaluator.AttributeStarting,Evaluator.AttributeWithValueMatching,Evaluator.Class,Evaluator.ContainsData,Evaluator.ContainsOwnText,Evaluator.ContainsText,Evaluator.ContainsWholeOwnText,Evaluator.ContainsWholeText,Evaluator.CssNthEvaluator,Evaluator.Id,Evaluator.IndexEvaluator,Evaluator.IsEmpty,Evaluator.IsFirstChild,Evaluator.IsLastChild,Evaluator.IsOnlyChild,Evaluator.IsOnlyOfType,Evaluator.IsRoot,Evaluator.Matches,Evaluator.MatchesOwn,Evaluator.MatchesWholeOwnText,Evaluator.MatchesWholeText,Evaluator.Tag,Evaluator.TagEndsWith,Evaluator.TagStartsWith
An Evaluator tests if an element (or a node) meets the selector's requirements. Obtain an evaluator for a given CSS selector
with
Selector.evaluatorOf(String css). If you are executing the same selector on many elements (or documents), it
can be more efficient to compile and reuse an Evaluator than to reparse the selector on each invocation of select().
Each evaluator captures the behavior selected by jsoup.queryMode when constructed.
Standalone evaluators use legacy behavior in check mode; they do not report compatibility differences.
If you construct and combine evaluators yourself, each child keeps the matching rules selected when it was created. The outer evaluator determines whether searches include the starting element and which element supplies the query context.
Evaluators are thread-safe and may be used concurrently across multiple documents.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classEvaluator for any / all element matchingstatic final classEvaluator for attribute name matchingstatic classAbstract evaluator for attribute name/value matchingstatic final classEvaluator for attribute name prefix matchingstatic final classEvaluator for attribute name/value matchingstatic final classEvaluator for attribute name/value matching (value containing)static final classEvaluator for attribute name/value matching (value ending)static final classEvaluator for attribute name/value matching (value regex matching)static final classEvaluator for attribute name !static final classEvaluator for attribute name/value matching (value prefix)static final classEvaluator for element classstatic final classEvaluator for matching Element (and its descendants) datastatic final classEvaluator for matching Element's own textstatic final classEvaluator for matching Element (and its descendants) textstatic final classEvaluator for matching Element (but not its descendants) wholeText.static final classEvaluator for matching Element (and its descendants) wholeText.static classstatic final classEvaluator for element idstatic final classEvaluator for matching by sibling index number (e = idx)static classAbstract evaluator for sibling index matchingstatic final classEvaluator for matching by sibling index number (e > idx)static final classEvaluator for matching by sibling index number (e < idx)static final classstatic final classEvaluator for matching the first sibling (css :first-child)static final classstatic final classEvaluator for matching the last sibling (css :last-child)static final classstatic final classcss-compatible Evaluator for :eq (css :nth-child)static final classcss pseudo class :nth-last-child)static classstatic classcss pseudo class nth-of-typestatic final classstatic final classstatic final classcss3 pseudo-class :rootstatic final classEvaluator for matching Element (and its descendants) text with regexstatic final classEvaluator for matching Element's own text with regexstatic final classEvaluator for matching Element's own whole text with regex.static final classEvaluator for matching Element (and its descendants) whole text with regex.static final classEvaluator for tag namestatic final classEvaluator for tag name that ends with suffix; used for *|elstatic final classEvaluator for tag name that starts with prefix; used for ns|* -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasPredicate(Element root) Provides a Predicate for this Evaluator, matching the test Element.protected intcost()A relative evaluator cost function.abstract booleanTests whether the element matches this evaluator.protected voidreset()Reset any internal state in this Evaluator before executing a new Collector evaluation.
-
Constructor Details
-
Evaluator
protected Evaluator()
-
-
Method Details
-
asPredicate
Provides a Predicate for this Evaluator, matching the test Element.- Parameters:
root- the element the query starts from; seematches(Element, Element)- Returns:
- a predicate that accepts an Element to test for matches with this Evaluator
- Since:
- 1.17.1
-
matches
Tests whether the element matches this evaluator.- Parameters:
root- the query context, used by:scope; for a Document,:scopematches its document elementelement- the element to test- Returns:
- whether the element matches
-
reset
Reset any internal state in this Evaluator before executing a new Collector evaluation. -
cost
A relative evaluator cost function. During evaluation, Evaluators are sorted by ascending cost as an optimization.- Returns:
- the relative cost of this Evaluator
-