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.MatchText,Evaluator.Tag,Evaluator.TagEndsWith,Evaluator.TagStartsWith
public abstract class Evaluator extends Object
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().
Evaluators are thread-safe and may be used concurrently across multiple documents.
-
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 classDeprecated.This selector is deprecated and will be removed in a future version.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 TypeMethodDescriptionPredicate<Element> asPredicate(Element root) Provides a Predicate for this Evaluator, matching the test Element.protected intcost()A relative evaluator cost function.abstract booleanTest if the element meets the evaluator's requirements.protected voidreset()Reset any internal state in this Evaluator before executing a new Collector evaluation.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
Method Details
-
asPredicate
Provides a Predicate for this Evaluator, matching the test Element.- Parameters:
-
root- the root Element, for match evaluation - Returns:
- a predicate that accepts an Element to test for matches with this Evaluator
- Since:
- 1.17.1
-
matches
Test if the element meets the evaluator's requirements.- Parameters:
-
root- Root of the matching subtree -
element- tested element - Returns:
- Returns true if the requirements are met or false otherwise
-
reset
protected void reset()Reset any internal state in this Evaluator before executing a new Collector evaluation. -
cost
protected int cost()A relative evaluator cost function. During evaluation, Evaluators are sorted by ascending cost as an optimization.- Returns:
- the relative cost of this Evaluator
-