Package adams.gui.core
Class ExtensionFileFilter
- java.lang.Object
-
- javax.swing.filechooser.FileFilter
-
- adams.gui.core.ExtensionFileFilter
-
- All Implemented Interfaces:
Serializable,Comparable<ExtensionFileFilter>
- Direct Known Subclasses:
ExtensionFileFilterWithClass,JComponentWriterFileFilter
public class ExtensionFileFilter extends FileFilter implements Comparable<ExtensionFileFilter>, Serializable
A FileFilter for filtering files base on their extension. Directories are always accepted.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringEXT_ALL_FILESthe "all files" extensions.protected booleanm_CaseSensitivewhether case-sensitive or not.protected Stringm_Descriptionthe description of the filter.protected String[]m_Extensionsthe extensions.
-
Constructor Summary
Constructors Constructor Description ExtensionFileFilter()Constructs 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccept(File f)Whether the given file is accepted by this filter.intcompareTo(ExtensionFileFilter o)Compares this image format with the specified filter for order.booleanequals(Object obj)Indicates whether some other object is "equal to" this one.static ExtensionFileFiltergetCommandLineFileFilter()Returns a filter for commandline setup files.static ExtensionFileFiltergetCsvFileFilter()Returns a filter for CSV files.StringgetDescription()The description of this filter.String[]getExtensions()Returns the extensions.static ExtensionFileFiltergetFlowFileFilter()Returns a filter for flow files.static ExtensionFileFiltergetLogFileFilter()Returns a filter for log files.static ExtensionFileFiltergetModelFileFilter()Returns a filter for model files.static ExtensionFileFiltergetPdfFileFilter()Returns a filter for PDF files.static ExtensionFileFiltergetPropertiesFileFilter()Returns a filter for props files.static ExtensionFileFiltergetSerializedModelFileFilter()Returns a filter for serialized model files.static ExtensionFileFiltergetTextFileFilter()Returns a filter for text files.static ExtensionFileFiltergetZipFileFilter()Returns a filter for ZIP files.booleanisCaseSensitive()Returns whether the filter is case-sensitive or not.StringtoString()Returns a short description of the filter.
-
-
-
Field Detail
-
EXT_ALL_FILES
public static final String EXT_ALL_FILES
the "all files" extensions.- See Also:
- Constant Field Values
-
m_Description
protected String m_Description
the description of the filter.
-
m_Extensions
protected String[] m_Extensions
the extensions.
-
m_CaseSensitive
protected boolean m_CaseSensitive
whether case-sensitive or not.
-
-
Constructor Detail
-
ExtensionFileFilter
public ExtensionFileFilter()
Constructs a filter that matches all files.
-
ExtensionFileFilter
public ExtensionFileFilter(String description, String extension)
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
public ExtensionFileFilter(String description, String[] extensions)
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
public ExtensionFileFilter(String description, String extension, boolean caseSensitive)
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
public ExtensionFileFilter(String description, String[] extensions, boolean caseSensitive)
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 Detail
-
accept
public boolean accept(File f)
Whether the given file is accepted by this filter.- Specified by:
acceptin classFileFilter- Parameters:
f- the file to check- Returns:
- true if accepted
-
getDescription
public String getDescription()
The description of this filter.- Specified by:
getDescriptionin classFileFilter- Returns:
- the description
-
getExtensions
public String[] 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
public int compareTo(ExtensionFileFilter o)
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
public boolean equals(Object obj)
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
public String toString()
Returns a short description of the filter.
-
getTextFileFilter
public static ExtensionFileFilter getTextFileFilter()
Returns a filter for text files.- Returns:
- the text filter
-
getFlowFileFilter
public static ExtensionFileFilter getFlowFileFilter()
Returns a filter for flow files.- Returns:
- the flow filter
-
getLogFileFilter
public static ExtensionFileFilter getLogFileFilter()
Returns a filter for log files.- Returns:
- the log filter
-
getPropertiesFileFilter
public static ExtensionFileFilter getPropertiesFileFilter()
Returns a filter for props files.- Returns:
- the props filter
-
getModelFileFilter
public static ExtensionFileFilter getModelFileFilter()
Returns a filter for model files.- Returns:
- the model filter
-
getCsvFileFilter
public static ExtensionFileFilter getCsvFileFilter()
Returns a filter for CSV files.- Returns:
- the CSV filter
-
getPdfFileFilter
public static ExtensionFileFilter getPdfFileFilter()
Returns a filter for PDF files.- Returns:
- the PDF filter
-
getZipFileFilter
public static ExtensionFileFilter getZipFileFilter()
Returns a filter for ZIP files.- Returns:
- the ZIP filter
-
getSerializedModelFileFilter
public static ExtensionFileFilter getSerializedModelFileFilter()
Returns a filter for serialized model files.- Returns:
- the model filter
-
getCommandLineFileFilter
public static ExtensionFileFilter getCommandLineFileFilter()
Returns a filter for commandline setup files.- Returns:
- the commandline filter
-
-