Package org.htmlparser.filters
Class HasChildFilter
java.lang.Object
org.htmlparser.filters.HasChildFilter
- All Implemented Interfaces:
Serializable
,Cloneable
,NodeFilter
This class accepts all tags that have a child acceptable to the filter.
It can be set to operate recursively, that is perform a scan down
through the node heirarchy in a breadth first traversal looking for any
descendant that matches the predicate filter (which stops the search).
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected NodeFilter
The filter to apply to children.protected boolean
Performs a recursive search down the node heirarchy iftrue
. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of a HasChildFilter.HasChildFilter
(NodeFilter filter) Creates a new instance of HasChildFilter that accepts nodes with a direct child acceptable to the filter.HasChildFilter
(NodeFilter filter, boolean recursive) Creates a new instance of HasChildFilter that accepts nodes with a child acceptable to the filter. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Accept tags with children acceptable to the filter.Get the filter used by this HasParentFilter.boolean
Get the recusion setting for the filter.void
setChildFilter
(NodeFilter filter) Set the filter for this HasParentFilter.void
setRecursive
(boolean recursive) Sets whether the filter is recursive or not.
-
Field Details
-
mChildFilter
The filter to apply to children. -
mRecursive
protected boolean mRecursivePerforms a recursive search down the node heirarchy iftrue
.
-
-
Constructor Details
-
HasChildFilter
public HasChildFilter()Creates a new instance of a HasChildFilter. With no child filter, this would always returnfalse
fromaccept(org.htmlparser.Node)
. -
HasChildFilter
Creates a new instance of HasChildFilter that accepts nodes with a direct child acceptable to the filter.- Parameters:
filter
- The filter to apply to the children.
-
HasChildFilter
Creates a new instance of HasChildFilter that accepts nodes with a child acceptable to the filter. Of necessity, this applies only to composite tags, i.e. those that can contain other nodes, for example <HTML></HTML>.- Parameters:
filter
- The filter to apply to children.recursive
- Iftrue
, any enclosed node acceptable to the given filter causes the node being tested to be accepted (i.e. a recursive scan through the child nodes down the node heirarchy is performed).
-
-
Method Details
-
getChildFilter
Get the filter used by this HasParentFilter.- Returns:
- The filter to apply to parents.
-
setChildFilter
Set the filter for this HasParentFilter.- Parameters:
filter
- The filter to apply to parents inaccept(org.htmlparser.Node)
.
-
getRecursive
public boolean getRecursive()Get the recusion setting for the filter.- Returns:
- Returns
true
if the filter is recursive up the node heirarchy.
-
setRecursive
public void setRecursive(boolean recursive) Sets whether the filter is recursive or not.- Parameters:
recursive
- The recursion setting for the filter.
-
accept
Accept tags with children acceptable to the filter.- Specified by:
accept
in interfaceNodeFilter
- Parameters:
node
- The node to check.- Returns:
true
if the node has an acceptable child,false
otherwise.
-