mavis.gui
Class GenericFileFilter

java.lang.Object
  extended by javax.swing.filechooser.FileFilter
      extended by mavis.gui.GenericFileFilter
All Implemented Interfaces:
java.io.FileFilter

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

A FileFilter for a FileChooser. Can be used to show only some file types, determined by extension.


Field Summary
private  java.lang.String description
          File type desription for the extensions.
private  java.lang.String[] extensions
          Extensions to be shown.
 
Constructor Summary
GenericFileFilter(java.lang.String description, java.lang.String... extensions)
          Creates a new file filter for the specified file type.
 
Method Summary
 boolean accept(java.io.File pathname)
          Tests whether or not the specified abstract pathname should be included in a pathname list.
 java.lang.String getDescription()
          Returns the file type description.
private static java.lang.String getExtension(java.io.File f)
          Returns the extension of the given file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

extensions

private java.lang.String[] extensions
Extensions to be shown.


description

private java.lang.String description
File type desription for the extensions.

Constructor Detail

GenericFileFilter

public GenericFileFilter(java.lang.String description,
                         java.lang.String... extensions)
Creates a new file filter for the specified file type. The file extensions can have "." prefixes or not.

Parameters:
description - a description for the file type, or null to have no description.
extensions - the file extensions that should be shown, or null to accept no extensions.
Method Detail

accept

public boolean accept(java.io.File pathname)
Tests whether or not the specified abstract pathname should be included in a pathname list.

Specified by:
accept in interface java.io.FileFilter
Specified by:
accept in class javax.swing.filechooser.FileFilter
Parameters:
pathname - the abstract pathname to be tested.
Returns:
true if and only if pathname should be included.

getExtension

private static java.lang.String getExtension(java.io.File f)
Returns the extension of the given file.

Parameters:
f - the file which's extension is wanted
Returns:
the characters after the last dot in the file name

getDescription

public java.lang.String getDescription()
Returns the file type description.

Specified by:
getDescription in class javax.swing.filechooser.FileFilter