Package xal.tools.apputils.files
Class FileFilterFactory
java.lang.Object
xal.tools.apputils.files.FileFilterFactory
FileFilterFactory generates file filters based on supplied file types.
- Author:
- tap
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a new instance of FileFilterFactory -
Method Summary
Modifier and TypeMethodDescriptionstatic JFileChooserapplyFileFilters(JFileChooser fileChooser, String[] fileTypes) Applies the file filters to the file chooser and returns this file chooser.static JFileChooserapplyFileFilters(JFileChooser fileChooser, String[] fileTypes, String[] fileDescriptions) Applies the file filters to the file chooser and returns this file chooser.protected static StringgetFileExtension(File file) Determine the file's extension.static FileFiltergetFileFilter(String fileType, String description) Create a file filter that accepts files of the specified type.static FileFiltergetSupportedFileFilter(String[] fileTypes) Create a file filter that accepts files of the specified types.protected static booleanDetermine whether the extension matches the file type.
-
Field Details
-
WILDCARD_FILE_EXTENSION
wildcard extension- See Also:
-
-
Constructor Details
-
FileFilterFactory
protected FileFilterFactory()Creates a new instance of FileFilterFactory
-
-
Method Details
-
applyFileFilters
public static JFileChooser applyFileFilters(JFileChooser fileChooser, String[] fileTypes, String[] fileDescriptions) Applies the file filters to the file chooser and returns this file chooser. Existing file filters are removed from the file chooser and then new file filters are added to the file chooser consistent with the specified file types and descriptions.- Parameters:
fileChooser- the file chooser to which to add the file filtersfileTypes- An array of file types to acceptfileDescriptions- An array of corresponding file type descriptions- Returns:
- The file chooser that accepts the specified file types (same file chooser as the argument)
-
applyFileFilters
Applies the file filters to the file chooser and returns this file chooser. Existing file filters are removed from the file chooser and then new file filters are added to the file chooser consistent with the specified file types.- Parameters:
fileChooser- the file chooser to which to add the file filtersfileTypes- An array of file types to accept- Returns:
- The file chooser that accepts the specified file types (same file chooser as the argument)
-
getFileFilter
Create a file filter that accepts files of the specified type. This is a supporting method for creating file choosers. A type is identified by its filename suffix.- Parameters:
fileType- File type to acceptdescription- the description of this file type- Returns:
- The file filter that accepts the specified file type
-
getSupportedFileFilter
Create a file filter that accepts files of the specified types. This is a supporting method for creating file choosers. A type is identified by its filename suffix.- Parameters:
fileTypes- Array of file types to accept- Returns:
- The file filter that accepts the specified file types
-
getFileExtension
Determine the file's extension.- Parameters:
file- the file for which to get the extension- Returns:
- the file's extension
-
isMatch
Determine whether the extension matches the file type. If the file type is the wildcard extension, then accept all extensions as matching.- Parameters:
extension- the file extension to test for matching to the file type.fileType- the file type against which to test for matching the file extension.- Returns:
- true if the extension matches the file type
-