com.compomics.util.io
Class FilenameExtensionFilter

java.lang.Object
  extended by javax.swing.filechooser.FileFilter
      extended by com.compomics.util.io.FilenameExtensionFilter
All Implemented Interfaces:
java.io.FilenameFilter

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

This class will implement a FilenameFilter that filters on the extension of files.

Author:
Lennart Martens

Constructor Summary
FilenameExtensionFilter(java.lang.String aExtension)
          This constructor takes an extension to filter on.
FilenameExtensionFilter(java.lang.String aExtension, java.lang.String aDescription)
          This constructor takes an extension to filter on.
 
Method Summary
 boolean accept(java.io.File f)
           
 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()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilenameExtensionFilter

public FilenameExtensionFilter(java.lang.String aExtension)
This constructor takes an extension to filter on. It doesn't care about a leading dot, so specifying '.class' is identical to 'class'.

Parameters:
aExtension - String with the extension to filter. Note that '.class' is identical to 'class'.

FilenameExtensionFilter

public FilenameExtensionFilter(java.lang.String aExtension,
                               java.lang.String aDescription)
This constructor takes an extension to filter on. It doesn't care about a leading dot, so specifying '.class' is identical to 'class'.

Parameters:
aExtension - String with the extension to filter. Note that '.class' is identical to 'class'.
aDescription - String with the description for the FileFilter. Can be null in which case the description will be an empty String.
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 f)
Specified by:
accept in class javax.swing.filechooser.FileFilter

getDescription

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


Copyright © 2012. All Rights Reserved.