org.w3c.dom.traversal
Interface NodeFilter
- public interface NodeFilter
Filters are objects that know how to "filter out" nodes. If a
NodeIterator
or TreeWalker
is given a filter, it
applies the filter before it returns the next node. If the filter says to
accept the node, the iterator returns it; otherwise, the iterator looks
for the next node and pretends that the node that was rejected was not
there.
The DOM does not provide any filters. Filter is just an interface that
users can implement to provide their own filters.
Filters do not need to know how to iterate, nor do they need to know
anything about the data structure that is being iterated. This makes it
very easy to write filters, since the only thing they have to know how to
do is evaluate a single node. One filter may be used with a number of
different kinds of iterators, encouraging code reuse. This is an
ECMAScript function reference. This method returns ashort
.
The parameter is of type Node
.
- Since:
- DOM Level 2
Method Summary |
short |
acceptNode(Node n)
Test whether a specified node is visible in the logical view of a
TreeWalker or NodeIterator. |
FILTER_ACCEPT
public static final short FILTER_ACCEPT
FILTER_REJECT
public static final short FILTER_REJECT
FILTER_SKIP
public static final short FILTER_SKIP
SHOW_ALL
public static final int SHOW_ALL
SHOW_ELEMENT
public static final int SHOW_ELEMENT
SHOW_ATTRIBUTE
public static final int SHOW_ATTRIBUTE
SHOW_TEXT
public static final int SHOW_TEXT
SHOW_CDATA_SECTION
public static final int SHOW_CDATA_SECTION
SHOW_ENTITY_REFERENCE
public static final int SHOW_ENTITY_REFERENCE
SHOW_ENTITY
public static final int SHOW_ENTITY
SHOW_PROCESSING_INSTRUCTION
public static final int SHOW_PROCESSING_INSTRUCTION
SHOW_COMMENT
public static final int SHOW_COMMENT
SHOW_DOCUMENT
public static final int SHOW_DOCUMENT
SHOW_DOCUMENT_TYPE
public static final int SHOW_DOCUMENT_TYPE
SHOW_DOCUMENT_FRAGMENT
public static final int SHOW_DOCUMENT_FRAGMENT
SHOW_NOTATION
public static final int SHOW_NOTATION
acceptNode
public short acceptNode(Node n)
- Test whether a specified node is visible in the logical view of a
TreeWalker or NodeIterator. This function will be called by the
implementation of TreeWalker and NodeIterator; it is not intended to
be called directly from user code.
- Parameters:
n
- The node to check to see if it passes the filter or not.- Returns:
- a constant to determine whether the node is accepted,
rejected, or skipped, as defined above .
Copyright © 1999 Apache XML Project. All Rights Reserved.