Package fr.esrf.tangoatk.widget.util
Class MultiExtFileFilter
java.lang.Object
javax.swing.filechooser.FileFilter
fr.esrf.tangoatk.widget.util.MultiExtFileFilter
A file filter that can accept multiple extensions (as for jpg, jpe, jpeg). The description is
automatically computed with the prefix followed by the list of extensions.
- Author:
- MAINGUY
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMultiExtFileFilter(String filterDescription, String defaultExtension, String... otherExtensions) -
Method Summary
Modifier and TypeMethodDescriptionbooleanprotected voidCompute the whole description for the filter.Return the default extension.static StringgetExtension(File f) returns the extension of a given file, that is the part after the last '.' in the filename.booleanisAccepted(String fileExtension) Return true if the specified extension is accepted by the filter.toString()
-
Field Details
-
prefix
-
extensions
-
description
-
-
Constructor Details
-
MultiExtFileFilter
public MultiExtFileFilter(String filterDescription, String defaultExtension, String... otherExtensions) - Parameters:
filterDescription- the description of the type of accepted filesdefaultExtension- a default extension. It ensures we have at least one extension.otherExtensions- more extensions for this type of files
-
-
Method Details
-
accept
- Specified by:
acceptin classFileFilter
-
getDescription
- Specified by:
getDescriptionin classFileFilter
-
isAccepted
Return true if the specified extension is accepted by the filter.- Parameters:
fileExtension- the fileExtension to test- Returns:
- true if the filter would accept this extension, false otherwise or if the extension is null
-
getDefaultExtension
Return the default extension. It can be useful when saving a file whose filename has no extension specified.- Returns:
- the default extension.
-
computeDescription
protected void computeDescription()Compute the whole description for the filter. User description is followed by allowed extensions as a list. -
toString
-
getExtension
returns the extension of a given file, that is the part after the last '.' in the filename. Result is in lower case.- Parameters:
f- the file- Returns:
- the extension if any, null otherwise
-