public abstract class Filter
extends java.lang.Object
getContents(Filter)
and removeContents(Filter)
methods to restrict what kinds of child-Content
are selected, or removed from under the current Content node. A Filter
can be created to match just one kind of Content (such as Text, Element,
Comment, Data, etc.) or several kinds of Content. A Filter can be
created to match Element or Attribute nodes with particular names, or
sets of names, or with particular Attribute values or Element contents,
or with content that satisfies an inequality comparison.
A Filter has an accept(Content)
method, which returns true,
if the type of the Content is accepted by the Filter. Internally,
filtering is performed by different kinds of algorithm, according to the
Filter subclass. If disparate kinds of Filter are combined using
logical-AND and logical-OR, this may return an AndFilter or OrFilter for
compound filtering. Similarly, the logical-NOT method may return a
NotFilter for complementary filtering.
Modifier and Type | Field and Description |
---|---|
static int |
ALLCONTENT
Bit-mask matching all Content node types, including the Document node.
|
static int |
NAMENODES
Bit-mask matching all Markup nodes with user-defined XML name tags.
|
static int |
PARENTNODES
Bit-mask matching all nodes that may be the parents of other nodes.
|
static int |
PROPERTYNODES
Bit-mask matching all nodes that can have XML attributes.
|
static int |
VALUENODES
Bit-mask matching all nodes containing XML data values.
|
static int |
XPATHNODES
Bit-mask matching all accessible XPath content, which excludes the
Declaration and Doctype nodes.
|
static int |
XPATHTEXT
Bit-mask matching all nodes that are treated as text by the XPath
text() selector. |
Modifier | Constructor and Description |
---|---|
protected |
Filter()
Creates a Filter.
|
Modifier and Type | Method and Description |
---|---|
abstract boolean |
accept(Content node)
Reports whether a given Content node is accepted by this Filter.
|
Filter |
and(Filter filter)
Creates a Filter that is the logical AND of this and another Filter.
|
protected IndexFilter |
andIndexFilter(IndexFilter filter)
Creates a Filter that is the logical AND of this and an IndexFilter.
|
protected Filter |
andNodeFilter(NodeFilter filter)
Creates a Filter that is the logical AND of this and a NodeFilter.
|
Filter |
not()
Creates a Filter that is the logical NOT of this Filter.
|
Filter |
or(Filter filter)
Creates a Filter that is the logical OR of this and another Filter.
|
protected Filter |
orNodeFilter(NodeFilter filter)
Creates a Filter that is the logical OR of this and a NodeFilter.
|
java.lang.String |
toString()
Returns a pretty representation of this Filter.
|
public static final int ALLCONTENT
public static final int NAMENODES
getName()
returns a name with user-defined
semantics, rather than just the content-type name of the node.public static final int VALUENODES
getText()
returns
some kind of value with user-defined semantics.public static final int PARENTNODES
public static final int PROPERTYNODES
public static final int XPATHNODES
public static final int XPATHTEXT
text()
selector. Includes the node types: Data and Text.public abstract boolean accept(Content node)
node
- a Content node.public Filter not()
public Filter and(Filter filter)
filter
- the other Filter.public Filter or(Filter filter)
filter
- the other Filter.protected IndexFilter andIndexFilter(IndexFilter filter)
filter
- the other IndexFilter.protected Filter andNodeFilter(NodeFilter filter)
filter
- the other NodeFilter.protected Filter orNodeFilter(NodeFilter filter)
filter
- the other NodeFilter.public java.lang.String toString()
toString
in class java.lang.Object