com.monkeycoder.monkeynes.base
Class GenericFileFilter

java.lang.Object
  |
  +--javax.swing.filechooser.FileFilter
        |
        +--com.monkeycoder.monkeynes.base.GenericFileFilter
All Implemented Interfaces:
FileFilter

public class GenericFileFilter
extends FileFilter
implements FileFilter

This provides completely generic file filtering for Swing based FileChooser dialogs.

Originally part of the MonkeyNES project.

Author:
David Stephens

Constructor Summary
GenericFileFilter()
          Creates an empty GenericFileFilter with no extensions, no description, and not showing directories.
GenericFileFilter(ArrayList inExtensions)
          Creates a GenericFileFilter with the extensions provided, no description, and not showing directories.
GenericFileFilter(ArrayList inExtensions, boolean inShowDirs)
          Creates a GenericFileFilter with the extensions provided, no description, and optionally showing directories.
GenericFileFilter(ArrayList inExtensions, String inDescription)
          Creates a GenericFileFilter with the extensions and description provided, and not showing directories.
GenericFileFilter(ArrayList inExtensions, String inDescription, boolean inShowDirs)
          Creates a GenericFileFilter with the extensions and description provided, and optionally showing directories.
GenericFileFilter(String inExtensions)
          Creates a GenericFileFilter with the extensions provided, no description, and not showing directories.
GenericFileFilter(String inExtensions, boolean inShowDirs)
          Creates a GenericFileFilter with the extensions provided, no description, and optionally showing directories.
GenericFileFilter(String inExtensions, String inDescription)
          Creates a GenericFileFilter with the extensions and description provided, and not showing directories.
GenericFileFilter(String inExtensions, String inDescription, boolean inShowDirs)
          Creates a GenericFileFilter with the extensions and description provided, and optionally showing directories.
 
Method Summary
 boolean accept(File inFile)
          Returns whether or not the specified file is to be shown.
 void addExtension(String inExt)
          Adds an extension to the list of extensions on which this GenericFileFilter filters.
 String getDescription()
          Gets the description.
 void setDescription(String inDesc)
          Sets the description.
 void setShowDirs(boolean inShowDirs)
          Sets whether or not directories will be shown.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericFileFilter

public GenericFileFilter()
Creates an empty GenericFileFilter with no extensions, no description, and not showing directories.


GenericFileFilter

public GenericFileFilter(ArrayList inExtensions)
Creates a GenericFileFilter with the extensions provided, no description, and not showing directories.

Parameters:
inExtensions - An ArrayList containing the extensions.

GenericFileFilter

public GenericFileFilter(ArrayList inExtensions,
                         boolean inShowDirs)
Creates a GenericFileFilter with the extensions provided, no description, and optionally showing directories.

Parameters:
inExtensions - An ArrayList containing the extensions.
inShowDirs - Whether or not to display directories with this filter.

GenericFileFilter

public GenericFileFilter(ArrayList inExtensions,
                         String inDescription)
Creates a GenericFileFilter with the extensions and description provided, and not showing directories.

Parameters:
inExtensions - An ArrayList containing the extensions.
inDescription - The description of this filter in the drop down list.

GenericFileFilter

public GenericFileFilter(ArrayList inExtensions,
                         String inDescription,
                         boolean inShowDirs)
Creates a GenericFileFilter with the extensions and description provided, and optionally showing directories.

Parameters:
inExtensions - An ArrayList containing the extensions.
inDescription - The description of this filter in the drop down list.
inShowDirs - Whether or not to display directories with this filter.

GenericFileFilter

public GenericFileFilter(String inExtensions)
Creates a GenericFileFilter with the extensions provided, no description, and not showing directories.

Parameters:
inExtensions - A pipe ('|') seperated string containing the extensions.

GenericFileFilter

public GenericFileFilter(String inExtensions,
                         boolean inShowDirs)
Creates a GenericFileFilter with the extensions provided, no description, and optionally showing directories.

Parameters:
inExtensions - A pipe ('|') seperated string containing the extensions.
inShowDirs - Whether or not to display directories with this filter.

GenericFileFilter

public GenericFileFilter(String inExtensions,
                         String inDescription)
Creates a GenericFileFilter with the extensions and description provided, and not showing directories.

Parameters:
inExtensions - A pipe ('|') seperated string containing the extensions.
inDescription - The description of this filter in the drop down list.

GenericFileFilter

public GenericFileFilter(String inExtensions,
                         String inDescription,
                         boolean inShowDirs)
Creates a GenericFileFilter with the extensions and description provided, and optionally showing directories.

Parameters:
inExtensions - A pipe ('|') seperated string containing the extensions.
inDescription - The description of this filter in the drop down list.
inShowDirs - Whether or not to display directories with this filter.
Method Detail

addExtension

public void addExtension(String inExt)
Adds an extension to the list of extensions on which this GenericFileFilter filters.

Parameters:
inExt - A string containing the extension to add.

setDescription

public void setDescription(String inDesc)
Sets the description.

Parameters:
inDesc - The description of this filter in the drop down list.

getDescription

public String getDescription()
Gets the description.

Specified by:
getDescription in class FileFilter
Returns:
The description that will show up in the drop down list.

setShowDirs

public void setShowDirs(boolean inShowDirs)
Sets whether or not directories will be shown.

Parameters:
inShowDirs - Whether or not to display directories with this filter.

accept

public boolean accept(File inFile)
Returns whether or not the specified file is to be shown.

Specified by:
accept in interface FileFilter
Specified by:
accept in class FileFilter
Parameters:
inFile - The file being tested.
Returns:
Whether or not the specified file is to be shown.