Package org.htmlparser.filters
Class HasAttributeFilter
- java.lang.Object
-
- org.htmlparser.filters.HasAttributeFilter
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,NodeFilter
public class HasAttributeFilter extends java.lang.Object implements NodeFilter
This class accepts all tags that have a certain attribute, and optionally, with a certain value.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringmAttributeThe attribute to check for.protected java.lang.StringmValueThe value to check for.
-
Constructor Summary
Constructors Constructor Description HasAttributeFilter()Creates a new instance of HasAttributeFilter.HasAttributeFilter(java.lang.String attribute)Creates a new instance of HasAttributeFilter that accepts tags with the given attribute.HasAttributeFilter(java.lang.String attribute, java.lang.String value)Creates a new instance of HasAttributeFilter that accepts tags with the given attribute and value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccept(Node node)Accept tags with a certain attribute.java.lang.StringgetAttributeName()Get the attribute name.java.lang.StringgetAttributeValue()Get the attribute value.voidsetAttributeName(java.lang.String name)Set the attribute name.voidsetAttributeValue(java.lang.String value)Set the attribute value.
-
-
-
Constructor Detail
-
HasAttributeFilter
public HasAttributeFilter()
Creates a new instance of HasAttributeFilter. With no attribute name, this would always returnfalsefromaccept(org.htmlparser.Node).
-
HasAttributeFilter
public HasAttributeFilter(java.lang.String attribute)
Creates a new instance of HasAttributeFilter that accepts tags with the given attribute.- Parameters:
attribute- The attribute to search for.
-
HasAttributeFilter
public HasAttributeFilter(java.lang.String attribute, java.lang.String value)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 Detail
-
getAttributeName
public java.lang.String getAttributeName()
Get the attribute name.- Returns:
- Returns the name of the attribute that is acceptable.
-
setAttributeName
public void setAttributeName(java.lang.String name)
Set the attribute name.- Parameters:
name- The name of the attribute to accept.
-
getAttributeValue
public java.lang.String getAttributeValue()
Get the attribute value.- Returns:
- Returns the value of the attribute that is acceptable.
-
setAttributeValue
public void setAttributeValue(java.lang.String value)
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
public boolean accept(Node node)
Accept tags with a certain attribute.- Specified by:
acceptin interfaceNodeFilter- Parameters:
node- The node to check.- Returns:
trueif the node has the attribute (and value if that is being checked too),falseotherwise.
-
-