com.jrefinery.report.util
Class FilesystemFilter

java.lang.Object
  extended byjavax.swing.filechooser.FileFilter
      extended bycom.jrefinery.report.util.FilesystemFilter
All Implemented Interfaces:
java.io.FilenameFilter

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

A generic filesystem filter which implements FilenameFilter and the Swing FileFilter. Multiple extensions can be registered for a single filetype.

Author:
Thomas Morgner

Constructor Summary
FilesystemFilter(java.lang.String[] fileext, java.lang.String descr, boolean accDirs)
          Creates a filesystem filter for the given extensions with the description supplied in descr.
FilesystemFilter(java.lang.String fileext, java.lang.String descr)
          Creates a filesystem filter for the given extension with the description supplied in descr.
FilesystemFilter(java.lang.String fileext, java.lang.String descr, boolean accDirs)
          Creates a filesystem filter for the given extension with the description supplied in descr.
 
Method Summary
 boolean accept(java.io.File dir)
          Whether the given file is accepted by this filter.
 boolean accept(java.io.File dir, java.lang.String name)
          Tests if a specified file should be included in a file list.
 void addExtension(java.lang.String ext)
          Add this extension to the filter.
 java.lang.String getDescription()
          The description of this filter.
 void setAcceptDirectories(boolean b)
          Sets whether this filter accepts directories.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilesystemFilter

public FilesystemFilter(java.lang.String fileext,
                        java.lang.String descr)
Creates a filesystem filter for the given extension with the description supplied in descr. Directories are accepted by default.

Parameters:
fileext - the file extension that should be accepted
descr - the description for this filetype

FilesystemFilter

public FilesystemFilter(java.lang.String fileext,
                        java.lang.String descr,
                        boolean accDirs)
Creates a filesystem filter for the given extension with the description supplied in descr. Directories are accepted if accDirs is set to true.

Parameters:
fileext - the file extension that should be accepted
descr - the description for this filetype
accDirs - true, if directories should be acceptable for this filter.

FilesystemFilter

public FilesystemFilter(java.lang.String[] fileext,
                        java.lang.String descr,
                        boolean accDirs)
Creates a filesystem filter for the given extensions with the description supplied in descr. Directories are accepted if accDirs is set to true.

Parameters:
fileext - the file extensions that should be accepted
descr - the description for this filetype
accDirs - true, if directories should be acceptable for this filter.
Method Detail

accept

public boolean accept(java.io.File dir,
                      java.lang.String name)
Tests if a specified file should be included in a file list.

Specified by:
accept in interface java.io.FilenameFilter
Parameters:
dir - the directory in which the file was found.
name - the name of the file.
Returns:
true if and only if the name should be included in the file list; false otherwise.

accept

public boolean accept(java.io.File dir)
Whether the given file is accepted by this filter.

Parameters:
dir - the file that should be checked.
Returns:
true, if the file should be accepted for this filter, false otherwise.

getDescription

public java.lang.String getDescription()
The description of this filter. For example: "JPG and GIF Images"

Returns:
the description for this filter.
See Also:
FileView.getName(java.io.File)

setAcceptDirectories

public void setAcceptDirectories(boolean b)
Sets whether this filter accepts directories.

Parameters:
b - set to true to accept directories, false otherwise

addExtension

public void addExtension(java.lang.String ext)
Add this extension to the filter.

Parameters:
ext - the extension that should be added to this filter.