org.pietschy.command.file
Class ExtensionFileFilter

java.lang.Object
  extended by javax.swing.filechooser.FileFilter
      extended by org.pietschy.command.file.ExtensionFileFilter

public class ExtensionFileFilter
extends javax.swing.filechooser.FileFilter

An implementation of FileFilter that is based on the extension of a file.

Version:
$Revision: 1.3 $
Author:
andrewp

Constructor Summary
ExtensionFileFilter(java.lang.String extension, java.lang.String description)
          Creates a new filter for the specified file extension with that has the specified description.
 
Method Summary
 boolean accept(java.io.File f)
          Accepts files that end with the specified extension.
 java.io.File checkAndAddExtension(java.io.File file)
          Checks that the specified file has an extension defined.
 java.lang.String getDescription()
           
 boolean isIgnoreCase()
           
 void setIgnoreCase(boolean ignoreCase)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtensionFileFilter

public ExtensionFileFilter(java.lang.String extension,
                           java.lang.String description)
Creates a new filter for the specified file extension with that has the specified description.

Parameters:
extension - the file extension to excluding the preceeding '.', ie "java", not ".java".
description - the user friendly description of the file filter.
Method Detail

accept

public boolean accept(java.io.File f)
Accepts files that end with the specified extension.

Specified by:
accept in class javax.swing.filechooser.FileFilter
Parameters:
f - the file to check.
Returns:
true if the file name ends with this filters extension.

getDescription

public java.lang.String getDescription()
Specified by:
getDescription in class javax.swing.filechooser.FileFilter

isIgnoreCase

public boolean isIgnoreCase()

setIgnoreCase

public void setIgnoreCase(boolean ignoreCase)

checkAndAddExtension

public java.io.File checkAndAddExtension(java.io.File file)
Checks that the specified file has an extension defined. If it does, it is returned as is, even if the extension doesn't match that of the filter. If no extension is specified, a new file is returned based on the original but with the extension defined by this filter.

Parameters:
file - the file to check.
Returns:
a file guarenteed to have the extension specified by this filter.