public class ElementMatcherSimpleCS extends Object implements ElementMatcher
Element.getAttribute() method provided by the DOM implementation returns
an empty string (not null) when the attribute is not defined.| Modifier and Type | Field and Description |
|---|---|
static String |
CLASS_ATTR |
static String |
CLASS_DELIM |
static String |
ID_ATTR |
| Constructor and Description |
|---|
ElementMatcherSimpleCS() |
| Modifier and Type | Method and Description |
|---|---|
Collection<String> |
elementClasses(Element e)
Obtains a collection of class names assigned to the given element
using its
class attribute. |
String |
elementID(Element e)
Obtains the ID of the given element when specified.
|
String |
elementName(Element e)
Obtains the name of the given element.
|
String |
getAttribute(Element e,
String name)
Obtains the value of an element attribute.
|
boolean |
matchesAttribute(Element e,
String name,
String value,
Selector.Operator o)
Checks whether the given element attribute has the given value.
|
boolean |
matchesClass(Element e,
String className)
Checks whether the given element has the given class assigned.
|
boolean |
matchesID(Element e,
String id)
Checks whether the given element has the given ID assigned.
|
boolean |
matchesName(Element e,
String name)
Checks whether the given element has the given name.
|
public static final String CLASS_DELIM
public static final String CLASS_ATTR
public static final String ID_ATTR
public String getAttribute(Element e, String name)
ElementMatchergetAttribute in interface ElementMatchere - The DOM element.name - Attribute name.public Collection<String> elementClasses(Element e)
ElementMatcherclass attribute.elementClasses in interface ElementMatchere - The DOM elementpublic boolean matchesClass(Element e, String className)
ElementMatchermatchesClass in interface ElementMatchere - The DOM elementclassName - the class name to checktrue when any of the element classes matches the given class.public String elementID(Element e)
ElementMatcherelementID in interface ElementMatchere - The DOM elementpublic boolean matchesID(Element e, String id)
ElementMatchermatchesID in interface ElementMatchere - The DOM elementid - the class name to checktrue when the element has the given ID.public String elementName(Element e)
ElementMatcherelementName in interface ElementMatchere - The DOM elementpublic boolean matchesName(Element e, String name)
ElementMatchermatchesName in interface ElementMatchere - The DOM elementname - the element name to checktrue when the element has the given name.public boolean matchesAttribute(Element e, String name, String value, Selector.Operator o)
ElementMatchermatchesAttribute in interface ElementMatchere - The DOM elementname - the attribute namevalue - the attribute valuetrue when the given attribute of the element has the given value.Copyright © 2019. All rights reserved.