edu.neu.ccs.util
Class FileExtensionFilter

java.lang.Object
  extended byjavax.swing.filechooser.FileFilter
      extended byedu.neu.ccs.util.FileExtensionFilter
All Implemented Interfaces:
FileFilter

public class FileExtensionFilter
extends FileFilter
implements FileFilter

Class FileExtensionFilter is a file filter that both extends javax.swing.filechooser.FileFilter and implements java.io.FileFilter; the filter uses 0 or more file extensions to determine whether or not to accept a file; the user can decide whether the matching should ignore case or be case sensitive; the default is to ignore case in the matching.

Because a filter of this class extends an abstract class and implements a related interface, such a filter may be passed to:

A filter of this class returns true for directories.

This class generalizes and supercedes the inner class ExtensionFileFilter of FileView but that class has been left in place for backward compatibility.


Field Summary
private  String[] arrayList
          The filter as an array of extensions.
private  String commaList
          The filter as a comma separated String.
private  String dialogDescription
          The description for file dialog boxes.
private  boolean ignoreCase
          Whether or not to ignore case in the match.
private  int N
          The length of extArray.
 
Constructor Summary
FileExtensionFilter()
          The default constructor that filters nothing.
FileExtensionFilter(String commaList)
          The constructor that filters files whose extensions are found in the given comma separated list.
FileExtensionFilter(String[] arrayList)
          The constructor that filters files whose extensions are found in the given String array.
FileExtensionFilter(String[] arrayList, boolean ignoreCase)
          The constructor that filters files whose extensions are found in the given String array and sets whether to ignore case in matching.
FileExtensionFilter(String commaList, boolean ignoreCase)
          The constructor that filters files whose extensions are found in the given comma separated list and sets whether to ignore case in matching.
 
Method Summary
 boolean accept(File f)
          Whether the given file is accepted by this filter.
 String getDescription()
          Returns the text description of the filtered files for a JFileChooser dialog box.
 String getExtensionsAsCommaList()
          Returns the extensions for this filter as a comma separated list.
 boolean getIgnoreCase()
          Returns the current ignore case setting.
protected  String makeStandardDescription()
          Create the standard dialog box description.
 void setExtensions(String commaList)
          Sets the extensions to filter using the given comma separated list.
 void setExtensions(String[] arrayList)
          Sets the extensions to filter using the given String array list.
 void setIgnoreCase(boolean ignoreCase)
          Sets whether to ignore case when matching a file name to an extension.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

commaList

private String commaList
The filter as a comma separated String.


arrayList

private String[] arrayList
The filter as an array of extensions.


N

private int N
The length of extArray.


ignoreCase

private boolean ignoreCase

Whether or not to ignore case in the match.

The default is true.


dialogDescription

private String dialogDescription
The description for file dialog boxes.

Constructor Detail

FileExtensionFilter

public FileExtensionFilter()
The default constructor that filters nothing.


FileExtensionFilter

public FileExtensionFilter(String commaList)

The constructor that filters files whose extensions are found in the given comma separated list.

By default, case is ignored in matching.

Parameters:
commaList - the comma separated list of extensions

FileExtensionFilter

public FileExtensionFilter(String[] arrayList)

The constructor that filters files whose extensions are found in the given String array.

By default, case is ignored in matching.

Parameters:
arrayList - the array list of extensions

FileExtensionFilter

public FileExtensionFilter(String commaList,
                           boolean ignoreCase)

The constructor that filters files whose extensions are found in the given comma separated list and sets whether to ignore case in matching.

Parameters:
commaList - the comma separated list of extensions
ignoreCase - whether to ignore case in matching

FileExtensionFilter

public FileExtensionFilter(String[] arrayList,
                           boolean ignoreCase)

The constructor that filters files whose extensions are found in the given String array and sets whether to ignore case in matching.

Parameters:
arrayList - the array list of extensions
ignoreCase - whether to ignore case in matching
Method Detail

setExtensions

public final void setExtensions(String commaList)

Sets the extensions to filter using the given comma separated list.

Parameters:
commaList - the comma separated list of extensions

setExtensions

public final void setExtensions(String[] arrayList)

Sets the extensions to filter using the given String array list.

Parameters:
arrayList - the array list of extensions

getExtensionsAsCommaList

public final String getExtensionsAsCommaList()
Returns the extensions for this filter as a comma separated list.


setIgnoreCase

public final void setIgnoreCase(boolean ignoreCase)

Sets whether to ignore case when matching a file name to an extension.

Parameters:
ignoreCase - whether to ignore case in matching

getIgnoreCase

public final boolean getIgnoreCase()
Returns the current ignore case setting.


accept

public final boolean accept(File f)

Whether the given file is accepted by this filter.

Specified by:
accept in interface FileFilter
Parameters:
f - the file to test

getDescription

public String getDescription()
Returns the text description of the filtered files for a JFileChooser dialog box.


makeStandardDescription

protected String makeStandardDescription()
Create the standard dialog box description.