|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.filechooser.FileFilter com.isti.util.IstiFileFilter
public class IstiFileFilter
A convenience implementation of FileFilter that filters out all files except for those type files that it knows about. Case is ignored. Example - create a new filter that filters out all files but gif and jpg image files: JFileChooser chooser = new JFileChooser(); IstiFileFilter filter = new IstiFileFilter( new String[]{"*.gif", "*.jpg"}, "JPEG & GIF Images") chooser.addChoosableFileFilter(filter); chooser.showOpenDialog(this);
Field Summary | |
---|---|
protected static boolean |
DEBUG_FLAG
|
protected static java.lang.String |
WC_STRING
|
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final boolean DEBUG_FLAG
protected static final java.lang.String WC_STRING
Constructor Detail |
---|
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)
Method Detail |
---|
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 string
FileFilter#accept
public static java.lang.String getPrefix(java.lang.String s)
s
- file name string
FileFilter#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 string
protected static boolean hasMultipleWildcards(java.lang.String filter)
filter
- filter file string
public static java.io.FileFilter createFileFilter(java.lang.String filter)
filter
- filter file string ("*.txt", "temp.*", "temp.txt", "*bak*")
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |