org.gjt.btools.ext
Class ExtensionFilenameFilter

java.lang.Object
  |
  +--javax.swing.filechooser.FileFilter
        |
        +--org.gjt.btools.ext.ExtensionFilenameFilter
All Implemented Interfaces:
java.io.FilenameFilter

public class ExtensionFilenameFilter
extends javax.swing.filechooser.FileFilter
implements java.io.FilenameFilter

A filename filter that accepts or rejects files based on their extension. Note that this class both implements java.io.FilenameFilter and extends javax.swing.filechooser.FileFilter.

A file will pass through this filter only if its name ends with the required string. String comparisons are not case sensitive.

All directories will be accepted by this filter; they will not be put through the extension test.


Constructor Summary
ExtensionFilenameFilter(java.lang.String extension, java.lang.String description)
          Creates a new filter that only accepts files ending with the given string (ignoring case).
 
Method Summary
 boolean accept(java.io.File file)
          Determines whether or not a file will pass through this filter.
 boolean accept(java.io.File dir, java.lang.String name)
          Determines whether or not a file will pass through this filter.
 java.lang.String getDescription()
          Returns a description of this filter.
 java.lang.String getExtension()
          Returns the extension associated with this filter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtensionFilenameFilter

public ExtensionFilenameFilter(java.lang.String extension,
                               java.lang.String description)
Creates a new filter that only accepts files ending with the given string (ignoring case).

Parameters:
extension - the string with which a filename should end. For correct results for standard dot extensions (.foo), this string should include the leading dot.
description - a description of this filter.
Method Detail

getExtension

public java.lang.String getExtension()
Returns the extension associated with this filter.

Returns:
the string with which a filename should end.

getDescription

public java.lang.String getDescription()
Returns a description of this filter.

Specified by:
getDescription in class javax.swing.filechooser.FileFilter
Returns:
a description of this filter.

accept

public boolean accept(java.io.File dir,
                      java.lang.String name)
Determines whether or not a file will pass through this filter.

Specified by:
accept in interface java.io.FilenameFilter
Parameters:
dir - the directory in which the file resides.
name - the name of the file.
Returns:
true if and only if the file is accepted by this filter.

accept

public boolean accept(java.io.File file)
Determines whether or not a file will pass through this filter.

Specified by:
accept in class javax.swing.filechooser.FileFilter
Parameters:
file - the file in question.
Returns:
true if and only if the file is accepted by this filter.


Copyright © 1998-2001, Ben Burton
This software is released under the GNU Public License.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@debian.org).