org.htmlparser.filters
Class HasParentFilter
- Cloneable, NodeFilter, Serializable
public class HasParentFilter
This class accepts all tags that have a parent acceptable to another filter.
It can be set to operate recursively, that is perform a scan up the node
heirarchy looking for any ancestor that matches the predicate filter.
End tags are not considered to be children of any tag.
HasParentFilter() - Creates a new instance of HasParentFilter.
|
HasParentFilter(NodeFilter filter) - Creates a new instance of HasParentFilter that accepts nodes with
the direct parent acceptable to the filter.
|
HasParentFilter(NodeFilter filter, boolean recursive) - Creates a new instance of HasParentFilter that accepts nodes with
a parent acceptable to the filter.
|
mParentFilter
protected NodeFilter mParentFilter
The filter to apply to the parent.
mRecursive
protected boolean mRecursive
Performs a recursive search up the node heirarchy if true
.
HasParentFilter
public HasParentFilter()
Creates a new instance of HasParentFilter.
With no parent filter, this would always return
false
from
accept(Node)
.
HasParentFilter
public HasParentFilter(NodeFilter filter)
Creates a new instance of HasParentFilter that accepts nodes with
the direct parent acceptable to the filter.
filter
- The filter to apply to the parent.
HasParentFilter
public HasParentFilter(NodeFilter filter,
boolean recursive)
Creates a new instance of HasParentFilter that accepts nodes with
a parent acceptable to the filter.
filter
- The filter to apply to the parent.recursive
- If true
, any enclosing node acceptable
to the given filter causes the node being tested to be accepted
(i.e. a recursive scan through the parent nodes up the node
heirarchy is performed).
accept
public boolean accept(Node node)
Accept tags with parent acceptable to the filter.
If recursion is enabled, each parent in turn up to
the topmost enclosing node is checked.
Recursion only proceeds while no parent satisfies the
filter.
- accept in interface NodeFilter
node
- The node to check.
true
if the node has an acceptable parent,
false
otherwise.
getParentFilter
public NodeFilter getParentFilter()
Get the filter used by this HasParentFilter.
- The filter to apply to parents.
getRecursive
public boolean getRecursive()
Get the recusion setting for the filter.
- Returns
true
if the filter is recursive
up the node heirarchy.
setParentFilter
public void setParentFilter(NodeFilter filter)
Set the filter for this HasParentFilter.
setRecursive
public void setRecursive(boolean recursive)
Sets whether the filter is recursive or not.
recursive
- The recursion setting for the filter.
| © 2005 Derrick Oswald Mai 08, 2008 |
HTML Parser is an open source library released under LGPL. |  |