com.mindprod.filter
Class MultiFilter

java.lang.Object
  extended by com.mindprod.filter.MultiFilter
All Implemented Interfaces:
java.io.FilenameFilter

public final class MultiFilter
extends java.lang.Object
implements java.io.FilenameFilter

Used to combine filters. Automatically filters out all directories, and/or files.

Since:
2003-06-06
Version:
2.7 2010-11-22 - add optional invert parameter on a number of the filters.
Author:
Roedy Green, Canadian Mind Products

Field Summary
static int BOTH
          code for requesting both files and directories.
static boolean DEBUGGING
          true if debugging.
static int DIRS
          code for requesting directories only
static int FILES
          Code for requesting files only.
 
Constructor Summary
MultiFilter(int want)
          constructor
 
Method Summary
 boolean accept(java.io.File dir, java.lang.String name)
          Select only files with that pass muster
 void addConsider(java.io.FilenameFilter consider)
          Add a FilenameFilter describing files you want to consider.
 void addMust(java.io.FilenameFilter must)
          Add a FilenameFilter describing the conditions that all files must pass.
 void addNever(java.io.FilenameFilter never)
          Add a FilenameFilter describing the files you want to reject.
static void main(java.lang.String[] args)
          TEST harness
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUGGING

public static final boolean DEBUGGING
true if debugging. Enables debugging harness.

See Also:
Constant Field Values

BOTH

public static final int BOTH
code for requesting both files and directories.

See Also:
Constant Field Values

DIRS

public static final int DIRS
code for requesting directories only

See Also:
Constant Field Values

FILES

public static final int FILES
Code for requesting files only.

See Also:
Constant Field Values
Constructor Detail

MultiFilter

public MultiFilter(int want)
constructor

Parameters:
want - What do you want returned FILES, DIRS or BOTH?
Method Detail

accept

public boolean accept(java.io.File dir,
                      java.lang.String name)
Select only files with that pass muster

Specified by:
accept in interface java.io.FilenameFilter
Parameters:
dir - the directory in which the file was found.
name - the name of the file
Returns:
true if and only if the name should be included in the file list; false otherwise.

addConsider

public void addConsider(java.io.FilenameFilter consider)
Add a FilenameFilter describing files you want to consider. Only one of the consider filters has to return true for the file to be considered for further processing. If you have no consider-type filters, then all files in the directory are considered. The results of all the consider filters are ORed together. Add the consider filters first that will catch the most files. If there is only one consider filter, it acts like a must filter. ExtensionListFilters, ClamFilters or RegexFilters are useful to list all the wild card extensions to consider.

Parameters:
consider - FilenameFilter, one of mine or anyone else's to consider in the combination.

addMust

public void addMust(java.io.FilenameFilter must)
Add a FilenameFilter describing the conditions that all files must pass. Only one of the must filters has to return false for the file to be rejected. If you have no must-type filters, then all considered files are used for further processing. The results of all the must filters are ANDed together. Add the must filters first that will reject the most files.

Parameters:
must - FileFilter to add.

addNever

public void addNever(java.io.FilenameFilter never)
Add a FilenameFilter describing the files you want to reject. These filters return true for files NOT wanted. All it takes is one of these never filters to return true, and the file will be rejected. If you have no never-type filters, then all considered and must-passing files are accepted. The results of all the never filters are NORed together. Add the never filters first that will return true to reject the most files. ListFilters are useful to provide a list of files to be excluded. ClamFilters can exclude a wildcard.

Parameters:
never - FilenameFilter to add

main

public static void main(java.lang.String[] args)
TEST harness

Parameters:
args - not used