mckay.utilities.general
Class FileFilterImplementation

java.lang.Object
  extended by javax.swing.filechooser.FileFilter
      extended by mckay.utilities.general.FileFilterImplementation
All Implemented Interfaces:
java.io.FileFilter

public class FileFilterImplementation
extends javax.swing.filechooser.FileFilter
implements java.io.FileFilter

A file filter for the JFileChooser class. Implements the two methods of the FileFilter abstract class.

Filters all files except directories and files that end with the given extension. Case is ignored.


Constructor Summary
FileFilterImplementation(java.lang.String[] extensions)
          Instantiate the FileFilterImplementation object to let files with the specified extension(s) pass.
 
Method Summary
 boolean accept(java.io.File f)
          Returns whether the given file should pass through the filter.
 java.lang.String getDescription()
          Returns a formatted list describing the file extensions that can pass the filter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileFilterImplementation

public FileFilterImplementation(java.lang.String[] extensions)
Instantiate the FileFilterImplementation object to let files with the specified extension(s) pass.

Parameters:
extensions - The extension(s) that this filter will allow to pass. Case is irrelevant, and the period should be omitted. For example, {"jpg", "jpeg"} should be passed if this is to apply to JPEG files. None of these may be null.
Method Detail

accept

public boolean accept(java.io.File f)
Returns whether the given file should pass through the filter.

Specified by:
accept in interface java.io.FileFilter
Specified by:
accept in class javax.swing.filechooser.FileFilter
Parameters:
f - The File to be tested.
Returns:
True if the File is a directory or has an acceptable extension, false otherwise.

getDescription

public java.lang.String getDescription()
Returns a formatted list describing the file extensions that can pass the filter.

Specified by:
getDescription in class javax.swing.filechooser.FileFilter
Returns:
The formatted list.