org.erowid.sperowider.urlfilter
Class AIncludeExcludeFilter

java.lang.Object
  extended byorg.erowid.sperowider.urlfilter.AIncludeExcludeFilter
Direct Known Subclasses:
RegexFilter, SimpleFilter

public abstract class AIncludeExcludeFilter
extends Object

Provides a basic frame for file/url filtering. The real benefit is the simple central model of configuration.

Version:
: $Header: /cvsroot/sperowider/SPEROWIDER_MODULE/javasource/org/erowid/sperowider/urlfilter/AIncludeExcludeFilter.java,v 1.1 2005/01/16 05:02:52 gurustu Exp $
Author:
: $Author: gurustu $

Constructor Summary
AIncludeExcludeFilter()
           
 
Method Summary
 void addExclude(Object exclude)
          Adds a string pattern to the list of patterns to exclude.
 void addInclude(Object include)
          Adds a string pattern to the list of patterns to include.
protected  List getExcludes()
          Returns the list of include patterns
protected  List getIncludes()
          Returns the list of include patterns
 void init(Element configNode)
          Initializes this SimpleURLFilter with a JDOM element that has an include and exclude pattern list.
protected abstract  boolean matchAny(List patternList, String name)
          Returns true if url matches any of the patterns in the list.
 boolean matchExcludes(String name)
          Returns true if any in the includes list is matched
 boolean matchIncludes(String name)
          Returns true if any in the includes list is matched
 String toString()
          Returns a meaningful string representation of this filter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AIncludeExcludeFilter

public AIncludeExcludeFilter()
Method Detail

addInclude

public void addInclude(Object include)
Adds a string pattern to the list of patterns to include.


addExclude

public void addExclude(Object exclude)
Adds a string pattern to the list of patterns to exclude.


getIncludes

protected List getIncludes()
Returns the list of include patterns


getExcludes

protected List getExcludes()
Returns the list of include patterns


init

public void init(Element configNode)
Initializes this SimpleURLFilter with a JDOM element that has an include and exclude pattern list.

Example :


 <filters>
      <includes>
          <include pattern="" />
          <include pattern="" />
      </includes>
      <excludes>
          <exclude pattern="" />
          <exclude pattern="" />
      </excludes>
 </filters>
 
Both includes and excludes are required, or a RuntimeException will be thrown.

Throws:
RuntimeException - When the includes or excludes section is missing

toString

public String toString()
Returns a meaningful string representation of this filter.


matchIncludes

public boolean matchIncludes(String name)
Returns true if any in the includes list is matched


matchExcludes

public boolean matchExcludes(String name)
Returns true if any in the includes list is matched


matchAny

protected abstract boolean matchAny(List patternList,
                                    String name)
Returns true if url matches any of the patterns in the list.


spero logo small Sperowider is
© 2005 Erowid.org