gate.util
Class ExtensionFileFilter

java.lang.Object
  extended by javax.swing.filechooser.FileFilter
      extended by gate.util.ExtensionFileFilter
All Implemented Interfaces:
FileFilter

public class ExtensionFileFilter
extends FileFilter
implements FileFilter

Implementation of a file name filter. This class is used by JFileChooser to filter the displayed files by their extension.


Field Summary
private  List<String> acceptedExtensions
          The list of accepted file name extensions.
private  String description
          The description of this file filter.
 
Constructor Summary
ExtensionFileFilter()
          Builds a new ExtensionFileFilter.
ExtensionFileFilter(String description, String... extensions)
          Creates a FileNameExtensionFilter with the specified description and file name extensions.
 
Method Summary
 boolean accept(File f)
          Checks a file for compliance with the requested extensions.
 void addExtension(String extension)
          Adds a new extension to the list of accepted extensions.
 String getDescription()
          Returns the user-frielndly description for the files, e.g.
 String[] getExtensions()
           
 void setDescription(String description)
          Sets the user friendly description for the accepted files.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

acceptedExtensions

private List<String> acceptedExtensions
The list of accepted file name extensions.


description

private String description
The description of this file filter.

Constructor Detail

ExtensionFileFilter

public ExtensionFileFilter()
Builds a new ExtensionFileFilter.


ExtensionFileFilter

public ExtensionFileFilter(String description,
                           String... extensions)
Creates a FileNameExtensionFilter with the specified description and file name extensions. The returned FileNameExtensionFilter will accept all directories and any file with a file name extension contained in extensions.

Parameters:
description - textual description for the filter, may be null
extensions - the accepted file name extensions
Method Detail

accept

public boolean accept(File f)
Checks a file for compliance with the requested extensions.

Specified by:
accept in interface FileFilter
Specified by:
accept in class FileFilter
Parameters:
f - file to test with this filter

getDescription

public String getDescription()
Returns the user-frielndly description for the files, e.g. "Text files"

Specified by:
getDescription in class FileFilter

addExtension

public void addExtension(String extension)
Adds a new extension to the list of accepted extensions.

Parameters:
extension - file extension used to filter files

setDescription

public void setDescription(String description)
Sets the user friendly description for the accepted files.

Parameters:
description - description for this file filter

getExtensions

public String[] getExtensions()
Returns:
the set of file name extensions files are tested against

toString

public String toString()
Overrides:
toString in class Object
Returns:
a string representation of this file filter.