com.mindprod.filter
Class ExtensionListFilter

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

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

Select a file based on it matches one of list of extensions.

Does not work with directories, see DirListFilter. see also FileListFilter and ClamFilter. Rejects all directories.

Since:
2005-06-30
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 boolean DEBUGGING
          true if debugging.
 
Constructor Summary
ExtensionListFilter(boolean invert, java.lang.String... want)
          constructor
ExtensionListFilter(java.lang.String... want)
          constructor
 
Method Summary
 boolean accept(java.io.File dir, java.lang.String name)
          Select only Files with an extension in our want list
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
Constructor Detail

ExtensionListFilter

public ExtensionListFilter(java.lang.String... want)
constructor

Parameters:
want - Array of simple file extension names, case insensitive, e.g. new String["html", "txt", "bat" ];

ExtensionListFilter

public ExtensionListFilter(boolean invert,
                           java.lang.String... want)
constructor

Parameters:
invert - if true, selects files not in the list instead.
want - Array of simple file extension names, case insensitive, e.g. new String["html", "txt", "bat" ];
Method Detail

accept

public boolean accept(java.io.File dir,
                      java.lang.String name)
Select only Files with an extension in our want list

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.

main

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

Parameters:
args - not used