public class IstiFileFilter
extends javax.swing.filechooser.FileFilter
implements java.io.FileFilter
Modifier and Type | Field and Description |
---|---|
protected static boolean |
DEBUG_FLAG |
protected static java.lang.String |
WC_STRING |
Constructor and Description |
---|
IstiFileFilter()
Creates a file filter.
|
IstiFileFilter(java.lang.String filter)
Creates a file filter that accepts the given file type.
|
IstiFileFilter(java.lang.String[] filters,
java.lang.String description)
Creates a file filter from the given string array and description.
|
IstiFileFilter(java.lang.String filter,
java.lang.String description)
Creates a file filter that accepts the given file type.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(java.io.File f)
Determines if this file should be shown in the directory pane.
|
void |
addFilter(java.lang.String filter)
Adds a filetype filter to filter against.
|
static java.io.FileFilter |
createFileFilter(java.lang.String filter)
Create the file filter for the specified filter string.
|
java.lang.String |
getDescription()
Returns the human readable description of this filter.
|
static java.lang.String |
getExtension(java.lang.String s)
Gets the extension portion of the string.
|
static java.lang.String |
getPrefix(java.lang.String s)
Gets the prefix portion of the string.
|
protected static boolean |
hasMultipleWildcards(java.lang.String filter)
Determines if the filter has multiple wildcards.
|
protected static boolean |
hasWildcards(java.lang.String filter)
Determines if the filter has wildcards.
|
boolean |
isAcceptingDirectories()
Determines if directories should always be accepted.
|
boolean |
isFilterListInDescription()
Determines whether the filter list (*.jpg, *.gif, etc) should
show up in the human readable description.
|
void |
setAcceptDirectories(boolean b)
Select if directories should always be accepted.
|
void |
setDescription(java.lang.String description)
Sets the human readable description of this filter.
|
void |
setFilterListInDescription(boolean b)
Determines whether the filter list (*.jpg, *.gif, etc) should
show up in the human readable description.
|
protected static final boolean DEBUG_FLAG
protected static final java.lang.String WC_STRING
public IstiFileFilter()
addFilter(java.lang.String)
,
By default all directories are accepted to allow directory traversal
with file choosers.
,
isAcceptingDirectories
,
setAcceptDirectories
public IstiFileFilter(java.lang.String filter)
filter
- filter file stringaddFilter(java.lang.String)
,
FileFilter
,
By default directories are not accepted for use with FileUtils.listFiles.
,
FileUtils.listFiles
,
isAcceptingDirectories
,
If a simple "java.io.FileFilter" is needed the 'createFileFilter' method
may be used.
,
createFileFilter
public IstiFileFilter(java.lang.String filter, java.lang.String description)
filter
- filter file string.description
- file description, or null for none.addFilter(java.lang.String)
,
FileFilter
,
By default all directories are accepted to allow directory traversal
with file choosers.
,
isAcceptingDirectories
,
setAcceptDirectories
public IstiFileFilter(java.lang.String[] filters, java.lang.String description)
filters
- array of filter file string.description
- file description, or null for none.addFilter(java.lang.String)
public boolean isAcceptingDirectories()
public void setAcceptDirectories(boolean b)
b
- true if always accepting directoriespublic boolean accept(java.io.File f)
accept
in interface java.io.FileFilter
accept
in class javax.swing.filechooser.FileFilter
f
- file#getFilter
,
FileFilter#accepts
public static java.lang.String getExtension(java.lang.String s)
s
- file name stringFileFilter#accept
public static java.lang.String getPrefix(java.lang.String s)
s
- file name stringFileFilter#accept
public void addFilter(java.lang.String filter)
filter
- filter file string
For example: the following code will create a filter that filters
out all files except those that end in "jpg" and "tif":
IstiFileFilter filter = new IstiFileFilter();
filter.addFilter("*.jpg");
filter.addFilter("*.tif");public java.lang.String getDescription()
getDescription
in class javax.swing.filechooser.FileFilter
setDescription
,
setFilterListInDescription
,
isFilterListInDescription
,
FileFilter#getDescription
public void setDescription(java.lang.String description)
description
- file description.
For example: filter.setDescription("Gif and JPG Images");setDescription
,
setFilterListInDescription
,
isFilterListInDescription
public void setFilterListInDescription(boolean b)
b
- true if the filter list should show up.
Only relevent if a description was provided in the constructor
or using setDescription();getDescription
,
setDescription
,
isFilterListInDescription
public boolean isFilterListInDescription()
getDescription
,
setDescription
,
setFilterListInDescription
protected static boolean hasWildcards(java.lang.String filter)
filter
- filter file stringprotected static boolean hasMultipleWildcards(java.lang.String filter)
filter
- filter file stringpublic static java.io.FileFilter createFileFilter(java.lang.String filter)
filter
- filter file string ("*.txt", "temp.*", "temp.txt", "*bak*")