Package nz.ac.waikato.cms.gui.core
Class ExtensionFileFilter
java.lang.Object
javax.swing.filechooser.FileFilter
nz.ac.waikato.cms.gui.core.ExtensionFileFilter
- All Implemented Interfaces:
Serializable,Comparable<ExtensionFileFilter>
public class ExtensionFileFilter
extends FileFilter
implements Comparable<ExtensionFileFilter>, Serializable
A FileFilter for filtering files base on their extension. Directories are
always accepted.
- Version:
- $Revision: 11193 $
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a filter that matches all files.ExtensionFileFilter(String description, String extension) Constructs a filter that matches files with the given extension, not case-sensitive.ExtensionFileFilter(String description, String[] extensions) Constructs a filter that matches files with the given extension, not case-sensitive.ExtensionFileFilter(String description, String[] extensions, boolean caseSensitive) Constructs a filter that matches files with the given extension, not case-sensitive.ExtensionFileFilter(String description, String extension, boolean caseSensitive) Constructs a filter that matches files with the given extension, not case-sensitive. -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether the given file is accepted by this filter.intCompares this image format with the specified filter for order.booleanIndicates whether some other object is "equal to" this one.static ExtensionFileFilterReturns a filter for CSV files.The description of this filter.String[]Returns the extensions.static ExtensionFileFilterReturns a filter for log files.static ExtensionFileFilterReturns a filter for PDF files.static ExtensionFileFilterReturns a filter for props files.static ExtensionFileFilterReturns a filter for text files.static ExtensionFileFilterReturns a filter for ZIP files.booleanReturns whether the filter is case-sensitive or not.toString()Returns a short description of the filter.
-
Field Details
-
EXT_ALL_FILES
the "all files" extensions.- See Also:
-
m_Description
the description of the filter. -
m_Extensions
the extensions. -
m_CaseSensitive
protected boolean m_CaseSensitivewhether case-sensitive or not.
-
-
Constructor Details
-
ExtensionFileFilter
public ExtensionFileFilter()Constructs a filter that matches all files. -
ExtensionFileFilter
Constructs a filter that matches files with the given extension, not case-sensitive.- Parameters:
description- the display stringextension- the extensions of the files (no dot!)
-
ExtensionFileFilter
Constructs a filter that matches files with the given extension, not case-sensitive.- Parameters:
description- the display stringextensions- the extensions of the files (no dot!)
-
ExtensionFileFilter
Constructs a filter that matches files with the given extension, not case-sensitive.- Parameters:
description- the display stringextension- the extensions of the files (no dot!)caseSensitive- if true then the filter is case-sensitive
-
ExtensionFileFilter
Constructs a filter that matches files with the given extension, not case-sensitive.- Parameters:
description- the display stringextensions- the extensions of the files (no dot!)caseSensitive- if true then the filter is case-sensitive
-
-
Method Details
-
accept
Whether the given file is accepted by this filter.- Specified by:
acceptin classFileFilter- Parameters:
f- the file to check- Returns:
- true if accepted
-
getDescription
The description of this filter.- Specified by:
getDescriptionin classFileFilter- Returns:
- the description
-
getExtensions
Returns the extensions.- Returns:
- the extensions
-
isCaseSensitive
public boolean isCaseSensitive()Returns whether the filter is case-sensitive or not.- Returns:
- true if case-sensitive
-
compareTo
Compares this image format with the specified filter for order. Returns a negative integer, zero, or a positive integer as this filter is less than, equal to, or greater than the specified filter.- Specified by:
compareToin interfaceComparable<ExtensionFileFilter>- Parameters:
o- the filter to be compared.- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
-
equals
Indicates whether some other object is "equal to" this one.
For some reason, we cannot override this method, using the result returned by the compareTo(ExtensionFileFilter) method. This results in the user no longer being able to change the file filter in the FileChooser dialog. -
toString
Returns a short description of the filter. -
getTextFileFilter
Returns a filter for text files.- Returns:
- the text filter
-
getLogFileFilter
Returns a filter for log files.- Returns:
- the log filter
-
getPropertiesFileFilter
Returns a filter for props files.- Returns:
- the props filter
-
getCsvFileFilter
Returns a filter for CSV files.- Returns:
- the CSV filter
-
getPdfFileFilter
Returns a filter for PDF files.- Returns:
- the PDF filter
-
getZipFileFilter
Returns a filter for ZIP files.- Returns:
- the ZIP filter
-