public class Basic_Filename_Filter
extends javax.swing.filechooser.FileFilter
implements java.io.FilenameFilter
FilenameFilter
, these extensions are used in comparison tests to
filter directory listings in the list methods of the File
class and by the AWT FileDialog
component. As a FileFilter
, they are used by the Swing
JFileChooser
.
Note: the "." before the extension is not needed. If provided, it will be ignored. Furthermore, all comparisons are performed in a case-insensitive manner (by coercing extensions to lowercase).
Regex_Filename_Filter
Modifier and Type | Field and Description |
---|---|
static Basic_Filename_Filter |
CSV |
static java.lang.String |
ID
Class identification name with source code version and date.
|
static Basic_Filename_Filter |
PTF |
static Basic_Filename_Filter |
TEXT |
Constructor and Description |
---|
Basic_Filename_Filter()
Creates a new filter with an empty extension list and no description.
|
Basic_Filename_Filter(java.lang.String[] extensions,
java.lang.String description)
Creates a new filter with the specified set of extensions and the given
description.
|
Basic_Filename_Filter(java.lang.String extension,
java.lang.String description)
Creates a new filter with the single specified extension and the given
description.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(java.io.File file)
Tests whether the specified file is accepted by this filter.
|
boolean |
accept(java.io.File directory,
java.lang.String name)
Tests whether the specified file is accepted by this filter.
|
void |
addExtension(java.lang.String extension)
Adds a single extension to the list of extensions currently used by this
filter.
|
java.lang.String |
description()
Deprecated.
Use
getDescription() instead. |
void |
description(java.lang.String description)
Deprecated.
Use
setDescription(String) instead. |
java.lang.String[] |
extensions()
Deprecated.
Use
getExtensions() instead. |
void |
extensions(java.lang.String[] extensions)
Deprecated.
Use
setExtensions(String[]) instead. |
java.lang.String |
getDescription()
Gets the description of this filter.
|
java.lang.String[] |
getExtensions()
Gets the list of extensions currently used by the filter.
|
java.lang.String |
removeExtension(java.lang.String extension)
Removes a single extension from the list of extensions currently used by
this filter.
|
void |
setDescription(java.lang.String description)
Sets the description of this filter.
|
void |
setExtensions(java.lang.String... extensions)
Sets the list of extensions currently used by this filter.
|
public static final java.lang.String ID
public static final Basic_Filename_Filter PTF
public static final Basic_Filename_Filter CSV
public static final Basic_Filename_Filter TEXT
public Basic_Filename_Filter()
public Basic_Filename_Filter(java.lang.String extension, java.lang.String description)
extension
- a filename extension; may be null.description
- the description of this filter; may be null.public Basic_Filename_Filter(java.lang.String[] extensions, java.lang.String description)
extensions
- a set of filename extensions; may be null.description
- the description of this filter; may be null.public java.lang.String[] getExtensions()
public void setExtensions(java.lang.String... extensions)
extensions
- the extensions this filter is to use; if this value is
null, all extensions will be removed and the filter will
accept all filenames.public java.lang.String getDescription()
getDescription
in class javax.swing.filechooser.FileFilter
public void setDescription(java.lang.String description)
description
- the new description of this filter.public boolean accept(java.io.File file)
If file is null, this method returns false.
If file is a directory, this method returns true.
If this filter's list of extensions is empty, this method returns true.
If file's extension matches any of this filter's extensions, this method returns true.
Otherwise, this method returns false, including the case where the file's name has no extension.
accept
in class javax.swing.filechooser.FileFilter
file
- the file in question.public boolean accept(java.io.File directory, java.lang.String name)
If name is null, this method returns false.
If this filter's list of extensions is empty, this method returns true.
If name's extension matches any of this filter's extensions, this method returns true.
Otherwise, this method returns false, including the case where the file's name has no extension.
accept
in interface java.io.FilenameFilter
directory
- the directory in which the file was found.name
- the file's name.public void addExtension(java.lang.String extension)
Note that the extension parameter is converted to lowercase, and everything up to an including the final "." is stripped from it before being added to the list.
extension
- the extension to add to the list of extensions; may be
null.public java.lang.String removeExtension(java.lang.String extension)
extension
- the extension to remove from the list of extensions; may
be null.@Deprecated public java.lang.String[] extensions()
getExtensions()
instead.@Deprecated public void extensions(java.lang.String[] extensions)
setExtensions(String[])
instead.@Deprecated public java.lang.String description()
getDescription()
instead.@Deprecated public void description(java.lang.String description)
setDescription(String)
instead.Copyright \ (C) Arizona Board of Regents on behalf of the \ Planetary Image Research Laboratory, Lunar and \ Planetary Laboratory at the University of Arizona