HTML Parser Home Page

org.htmlparser.filters
Class LinkRegexFilter

java.lang.Object
  extended by org.htmlparser.filters.LinkRegexFilter
All Implemented Interfaces:
Serializable, Cloneable, NodeFilter

public class LinkRegexFilter
extends Object
implements NodeFilter

This class accepts tags of class LinkTag that contain a link matching a given regex pattern. Use this filter to extract LinkTag nodes with URLs that match the desired regex pattern.

See Also:
Serialized Form

Field Summary
protected  Pattern mRegex
          The regular expression to use on the link.
 
Constructor Summary
LinkRegexFilter(String regexPattern)
          Creates a LinkRegexFilter that accepts LinkTag nodes containing a URL that matches the supplied regex pattern.
LinkRegexFilter(String regexPattern, boolean caseSensitive)
          Creates a LinkRegexFilter that accepts LinkTag nodes containing a URL that matches the supplied regex pattern.
 
Method Summary
 boolean accept(Node node)
          Accept nodes that are a LinkTag and have a URL that matches the regex pattern supplied in the constructor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mRegex

protected Pattern mRegex
The regular expression to use on the link.

Constructor Detail

LinkRegexFilter

public LinkRegexFilter(String regexPattern)
Creates a LinkRegexFilter that accepts LinkTag nodes containing a URL that matches the supplied regex pattern. The match is case insensitive.

Parameters:
regexPattern - The pattern to match.

LinkRegexFilter

public LinkRegexFilter(String regexPattern,
                       boolean caseSensitive)
Creates a LinkRegexFilter that accepts LinkTag nodes containing a URL that matches the supplied regex pattern.

Parameters:
regexPattern - The regex pattern to match.
caseSensitive - Specifies case sensitivity for the matching process.
Method Detail

accept

public boolean accept(Node node)
Accept nodes that are a LinkTag and have a URL that matches the regex pattern supplied in the constructor.

Specified by:
accept in interface NodeFilter
Parameters:
node - The node to check.
Returns:
true if the node is a link with the pattern.

© 2006 Derrick Oswald
Sep 17, 2006

HTML Parser is an open source library released under Common Public License. SourceForge.net