Package org.htmlparser.filters
Class HasAttributeFilter
java.lang.Object
org.htmlparser.filters.HasAttributeFilter
- All Implemented Interfaces:
Serializable
,Cloneable
,NodeFilter
This class accepts all tags that have a certain attribute,
and optionally, with a certain value.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of HasAttributeFilter.HasAttributeFilter
(String attribute) Creates a new instance of HasAttributeFilter that accepts tags with the given attribute.HasAttributeFilter
(String attribute, String value) Creates a new instance of HasAttributeFilter that accepts tags with the given attribute and value. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Accept tags with a certain attribute.Get the attribute name.Get the attribute value.void
setAttributeName
(String name) Set the attribute name.void
setAttributeValue
(String value) Set the attribute value.
-
Field Details
-
mAttribute
The attribute to check for. -
mValue
The value to check for.
-
-
Constructor Details
-
HasAttributeFilter
public HasAttributeFilter()Creates a new instance of HasAttributeFilter. With no attribute name, this would always returnfalse
fromaccept(org.htmlparser.Node)
. -
HasAttributeFilter
Creates a new instance of HasAttributeFilter that accepts tags with the given attribute.- Parameters:
attribute
- The attribute to search for.
-
HasAttributeFilter
Creates a new instance of HasAttributeFilter that accepts tags with the given attribute and value.- Parameters:
attribute
- The attribute to search for.value
- The value that must be matched, or null if any value will match.
-
-
Method Details
-
getAttributeName
Get the attribute name.- Returns:
- Returns the name of the attribute that is acceptable.
-
setAttributeName
Set the attribute name.- Parameters:
name
- The name of the attribute to accept.
-
getAttributeValue
Get the attribute value.- Returns:
- Returns the value of the attribute that is acceptable.
-
setAttributeValue
Set the attribute value.- Parameters:
value
- The value of the attribute to accept. Ifnull
, any tag with the attribute, no matter what it's value is acceptable.
-
accept
Accept tags with a certain attribute.- Specified by:
accept
in interfaceNodeFilter
- Parameters:
node
- The node to check.- Returns:
true
if the node has the attribute (and value if that is being checked too),false
otherwise.
-