public class ValueFilter extends MaskFilter
ValueFilter has an accept(Content)
method, which returns true,
if the Content node is an acceptable type and the comparison of the node's
value against the reference value succeeds. The node's value is extracted
using the getText()
method. Comparison succeeds if this text
value is equal to the reference pattern, according to String comparison.
ValueFilter is less general than RestrictFilter, which supports a variety
of restrictions including equality, but is more efficient, since it does
not need to convert values into other primitive types.
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
value
The reference value for this ValueFilter.
|
mask
ALLCONTENT, NAMENODES, PARENTNODES, PROPERTYNODES, VALUENODES, XPATHNODES, XPATHTEXT
Constructor and Description |
---|
ValueFilter(java.lang.String value)
Creates a ValueFilter that filters for nodes having the given value.
|
ValueFilter(java.lang.String value,
int contentType)
Creates a ValueFilter for nodes of the given content-type having the
given value.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(Content node)
Reports whether a given Content node is accepted by this ValueFilter.
|
protected ValueFilter |
andNodeFilter(NodeFilter other)
Creates a Filter that is the conjunction of this ValueFilter and a
NodeFilter.
|
getMask
and, andIndexFilter, not, or, orNodeFilter, toString
public ValueFilter(java.lang.String value)
value
- the reference value to match.public ValueFilter(java.lang.String value, int contentType)
value
- the reference value to match.contentType
- a bit-mask specifying one or more content-types.public boolean accept(Content node)
accept
in class MaskFilter
node
- a Content node.protected ValueFilter andNodeFilter(NodeFilter other)
andNodeFilter
in class Filter
other
- the other NodeFilter.