Copyright 2012-02-25 Werner Randelshofer

ch.randelshofer.io
Class ExtensionFileFilter

java.lang.Object
  extended by javax.swing.filechooser.FileFilter
      extended by ch.randelshofer.io.ExtensionFileFilter
All Implemented Interfaces:
java.io.FileFilter, java.io.FilenameFilter

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

Accepts all directories, and all files which have the given extensions.

Version:
1.00 2001-10-14
Author:
Werner Randelshofer

Constructor Summary
ExtensionFileFilter(java.lang.String[] extensions, java.lang.String description)
          Creates new ExtensionFileFilter which accepts all directories and all files with the given extension.
ExtensionFileFilter(java.lang.String extension, java.lang.String description)
          Creates new ExtensionFileFilter which accepts all directories and all files with the given extension.
 
Method Summary
 boolean accept(java.io.File f)
          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.
 java.lang.String getDescription()
          The description of this filter.
 java.lang.String getExtension(java.lang.String filename)
           
 
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 new ExtensionFileFilter which accepts all directories and all files with the given extension.

Parameters:
extension - The extension which shall be accepted.
description - The description of the FileFilter

ExtensionFileFilter

public ExtensionFileFilter(java.lang.String[] extensions,
                           java.lang.String description)
Creates new ExtensionFileFilter which accepts all directories and all files with the given extension.

Parameters:
extensions - The extension which shall be accepted.
description - The description of the FileFilter
Method Detail

accept

public boolean accept(java.io.File f)
Whether the given file is accepted by this filter. Accepts all directories, and all XML files.

Specified by:
accept in interface java.io.FileFilter
Specified by:
accept in class javax.swing.filechooser.FileFilter

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.

getDescription

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

Specified by:
getDescription in class javax.swing.filechooser.FileFilter
See Also:
FileView.getName(java.io.File)

getExtension

public java.lang.String getExtension(java.lang.String filename)

Copyright 2012-02-25 Werner Randelshofer