danger.content
Class PathFilter

java.lang.Object
  extended by danger.content.ContentFilter
      extended by danger.content.PathFilter


public class PathFilter
extends ContentFilter

A filter that is based on path.

Here's an example of a path filter that includes all files under a particular path:

 PathFilter pathFilter = new PathFilter();
 pathFilter.includePath("/removable0/themes", -1);
 


Field Summary
static int PATH_FILTER_INCLUDE_ALL
           
static int PATH_FILTER_INCLUDE_ONLY_ME
           
 
Constructor Summary
PathFilter()
          Construct a new filter that by default excludes all paths.
PathFilter(boolean includeAll)
          Construct a new filter that uses the specified flag to determine whether it includes or excludes all paths by default.
 
Method Summary
 boolean accept(ContentFile file)
          The filtering logic.
 void dump()
          Used for debugging purposes.
 void excludePath(String path)
          Specify a path to exclude from the filter.
 void includePath(String path, int depth)
          Specify a path to include in the filter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PATH_FILTER_INCLUDE_ALL

public static final int PATH_FILTER_INCLUDE_ALL
See Also:
Constant Field Values

PATH_FILTER_INCLUDE_ONLY_ME

public static final int PATH_FILTER_INCLUDE_ONLY_ME
See Also:
Constant Field Values
Constructor Detail

PathFilter

public PathFilter()
Construct a new filter that by default excludes all paths.


PathFilter

public PathFilter(boolean includeAll)
Construct a new filter that uses the specified flag to determine whether it includes or excludes all paths by default.

Method Detail

includePath

public void includePath(String path,
                        int depth)
Specify a path to include in the filter.

The depth parameter is used as follows:

Parameters:
path - Path to include.
depth - The number of directory levels under this path to include in the filter, as described above.
Throws:
IllegalStateException - if filter is inclusive

excludePath

public void excludePath(String path)
Specify a path to exclude from the filter.

Throws:
IllegalStateException - if filter is exclusive

accept

public boolean accept(ContentFile file)
               throws StoreException
Description copied from class: ContentFilter
The filtering logic. Return true if the filter accepts the passed-in file, and false if not.

Specified by:
accept in class ContentFilter
Throws:
StoreException

dump

public void dump()
Description copied from class: ContentFilter
Used for debugging purposes.

Overrides:
dump in class ContentFilter