com.saic.isd.swing.filechooser
Class SimpleFileFilter

java.lang.Object
  extended byjavax.swing.filechooser.FileFilter
      extended bycom.saic.isd.swing.filechooser.SimpleFileFilter

public class SimpleFileFilter
extends javax.swing.filechooser.FileFilter

A file filter which determines what files to accept for a given extension, also accepting all directories. An extension refers to the part of a file name after the final period. Here are some examples:
file.txt - txt is the extension
network.xml - xml is the extension
SAIC.RunThis.pl - pl is the extension
a.ridiculus.example.doc - doc is the extension
foo - there is no extension

Code originally borrowed from:
Sun's ExampleFileFilter version 1.9 by Jeff Dinkins


Constructor Summary
SimpleFileFilter(java.lang.String extension)
          Creates a new FileFilter which will accept files based on the extension provided, ignoring case.
SimpleFileFilter(java.lang.String extension, java.lang.String description)
          Creates a new FileFilter which will accept files based on the extension provided, ignoring case.
SimpleFileFilter(java.lang.String extension, java.lang.String description, boolean caseSensitive)
          Creates a new FileFilter which will accept files based on the extension provided.
 
Method Summary
 boolean accept(java.io.File f)
          Tests a file for acceptability.
 java.io.File attachExtension(java.io.File file)
          Adds the extension to a file if it does not have that extension already.
 java.lang.String getDescription()
           
 java.lang.String getExtension()
          Gets the extendsion.
static java.lang.String getExtension(java.io.File f)
          Returns the extension of a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleFileFilter

public SimpleFileFilter(java.lang.String extension)
Creates a new FileFilter which will accept files based on the extension provided, ignoring case.

Parameters:
extension - Required, may not contain a period.

SimpleFileFilter

public SimpleFileFilter(java.lang.String extension,
                        java.lang.String description)
Creates a new FileFilter which will accept files based on the extension provided, ignoring case.

Parameters:
extension - Required, may not contain a period.
description -

SimpleFileFilter

public SimpleFileFilter(java.lang.String extension,
                        java.lang.String description,
                        boolean caseSensitive)
Creates a new FileFilter which will accept files based on the extension provided.

Parameters:
extension - Required, may not contain a period.
description -
caseSensitive - if true the extension's case must match exactly.
Method Detail

getDescription

public java.lang.String getDescription()

accept

public boolean accept(java.io.File f)
Tests a file for acceptability.

Returns:
Whether the given file is accepted by this filter.

getExtension

public java.lang.String getExtension()
Gets the extendsion.

Returns:
extenion used for this filter

attachExtension

public java.io.File attachExtension(java.io.File file)
Adds the extension to a file if it does not have that extension already.

Parameters:
file -
Returns:
file with the extesion added

getExtension

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

Parameters:
f - nulls not permitted.
Returns:
extension returns null if there is no extension.


Copyright © 2002 Gerhard Beck. All rights reserved. Subject to GPL.