Package org.htmlparser.filters
Class XorFilter
java.lang.Object
org.htmlparser.filters.XorFilter
- All Implemented Interfaces:
Serializable
,Cloneable
,NodeFilter
Accepts nodes matching an odd number of its predicates filters (XOR operation).
For example, where it has two filters, it accepts only if and only if one of the two filters accepts the Node, but does not accept if both filters accept the Node.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected NodeFilter[]
The predicates that are to be xor'ed together; -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of an XorFilter.XorFilter
(NodeFilter[] predicates) Creates an XorFilter that accepts nodes acceptable an odd number of the given filters.XorFilter
(NodeFilter left, NodeFilter right) Creates an XorFilter that accepts nodes acceptable to either filter, but not both. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Accept nodes that are acceptable to an odd number of its predicate filters.Get the predicates used by this XorFilter.void
setPredicates
(NodeFilter[] predicates) Set the predicates for this XorFilter.
-
Field Details
-
mPredicates
The predicates that are to be xor'ed together;
-
-
Constructor Details
-
XorFilter
public XorFilter()Creates a new instance of an XorFilter. With no predicates, this would always answerfalse
toaccept(org.htmlparser.Node)
. -
XorFilter
Creates an XorFilter that accepts nodes acceptable to either filter, but not both.- Parameters:
left
- One filter.right
- The other filter.
-
XorFilter
Creates an XorFilter that accepts nodes acceptable an odd number of the given filters.- Parameters:
predicates
- The list of filters.
-
-
Method Details
-
getPredicates
Get the predicates used by this XorFilter.- Returns:
- The predicates currently in use.
-
setPredicates
Set the predicates for this XorFilter.- Parameters:
predicates
- The list of predidcates to use inaccept(org.htmlparser.Node)
.
-
accept
Accept nodes that are acceptable to an odd number of its predicate filters.- Specified by:
accept
in interfaceNodeFilter
- Parameters:
node
- The node to check.- Returns:
true
if an odd number of the predicate filters find the node is acceptable,false
otherwise.
-