Package weka.gui
Class ExtensionFileFilter
- java.lang.Object
-
- javax.swing.filechooser.FileFilter
-
- weka.gui.ExtensionFileFilter
-
- All Implemented Interfaces:
FilenameFilter,Serializable
- Direct Known Subclasses:
ExtensionFileFilterWithClass
public class ExtensionFileFilter extends FileFilter implements FilenameFilter, Serializable
Provides a file filter for FileChoosers that accepts or rejects files based on their extension. Compatible with both java.io.FilenameFilter and javax.swing.filechooser.FileFilter (why there are two I have no idea).- Version:
- $Revision$
- Author:
- Len Trigg (trigg@cs.waikato.ac.nz)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ExtensionFileFilter(String[] extensions, String description)Creates an ExtensionFileFilter that accepts files that have any of the extensions contained in the supplied array.ExtensionFileFilter(String extension, String description)Creates the ExtensionFileFilter
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccept(File file)Returns true if the supplied file should be accepted (i.e.: if it has the required extension or is a directory).booleanaccept(File dir, String name)Returns true if the file in the given directory with the given name should be accepted.StringgetDescription()Gets the description of accepted files.String[]getExtensions()Returns a copy of the acceptable extensions.
-
-
-
Constructor Detail
-
ExtensionFileFilter
public ExtensionFileFilter(String extension, String description)
Creates the ExtensionFileFilter- Parameters:
extension- the extension of accepted files.description- a text description of accepted files.
-
ExtensionFileFilter
public ExtensionFileFilter(String[] extensions, String description)
Creates an ExtensionFileFilter that accepts files that have any of the extensions contained in the supplied array.- Parameters:
extensions- an array of acceptable file extensions (as Strings).description- a text description of accepted files.
-
-
Method Detail
-
getDescription
public String getDescription()
Gets the description of accepted files.- Specified by:
getDescriptionin classFileFilter- Returns:
- the description.
-
getExtensions
public String[] getExtensions()
Returns a copy of the acceptable extensions.- Returns:
- the accepted extensions
-
accept
public boolean accept(File file)
Returns true if the supplied file should be accepted (i.e.: if it has the required extension or is a directory).- Specified by:
acceptin classFileFilter- Parameters:
file- the file of interest.- Returns:
- true if the file is accepted by the filter.
-
accept
public boolean accept(File dir, String name)
Returns true if the file in the given directory with the given name should be accepted.- Specified by:
acceptin interfaceFilenameFilter- Parameters:
dir- the directory where the file resides.name- the name of the file.- Returns:
- true if the file is accepted.
-
-