Package org.esa.snap.core.util.io
Class SnapFileFilter
java.lang.Object
javax.swing.filechooser.FileFilter
org.esa.snap.core.util.io.SnapFileFilter
- Direct Known Subclasses:
DimapFileFilter
A
FileFilter with file extensions support.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumFile selection modes. -
Constructor Summary
ConstructorsConstructorDescriptionSnapFileFilter(String formatName, String[] extensions, String description) SnapFileFilter(String formatName, String extension, String description) -
Method Summary
Modifier and TypeMethodDescriptionbooleanTests whether or not the given file is accepted by this filter.booleancheckExtension(File file) Utility method which checks the extension the given file.booleancheckExtension(String filename) Utility method which checks the extension the given filename.static booleancheckExtensions(String filename, String[] extensions) Utility method which checks the extension the given filename.booleanReturns the default extension.Returns the description of this filter.String[]Returns the accepted extensions of this filter.Gets the file selection mode for theJFileChooserif this filter is used.static <T extends ProductIOPlugIn>
List<SnapFileFilter> getSortedFileFilters(Iterator<T> pluginIterator) Return a alphabetically sorted list of file filters originating from a productIO plugin iterator.booleanReturns whether or not this file filter has extensions.inthashCode()booleanisCompoundDocument(File dir) Checks if the given directory represents a compound document.voidsetDescription(String description) Returns the description of this filter.voidsetExtensions(String[] extensions) Sets the accepted extensions of this filter.voidsetFormatName(String formatName)
-
Constructor Details
-
SnapFileFilter
public SnapFileFilter() -
SnapFileFilter
-
SnapFileFilter
-
-
Method Details
-
equals
-
hashCode
public int hashCode() -
getFormatName
-
setFormatName
-
hasExtensions
public boolean hasExtensions()Returns whether or not this file filter has extensions.- Returns:
trueif so
-
getDefaultExtension
Returns the default extension. The default extension is the first entry in the array returned by thegetExtensionsmethod.- Returns:
- the default extension or
nullif no extensions have bees specified. - See Also:
-
getExtensions
Returns the accepted extensions of this filter. For example:{".jpg", ".gif", ".png"}.- Returns:
- The array of extensions.
- See Also:
-
setExtensions
Sets the accepted extensions of this filter. For example:{".jpg", ".gif", ".png"}.- Parameters:
extensions- The array of extensions.- See Also:
-
getDescription
Returns the description of this filter. For example:"JPEG Images (*.jpg,*.jpeg)".- Specified by:
getDescriptionin classFileFilter- See Also:
-
setDescription
Returns the description of this filter. For example:"JPEG Images (*.jpg,*.jpeg)". If the extension list is missing in the description text, it is automatically appended.- Parameters:
description- The description, must not be null.- See Also:
-
checkExtension
Utility method which checks the extension the given file.- Parameters:
file- the file- Returns:
trueif the given file path ends with one of the registered extensions,falseotherwise.
-
checkExtension
Utility method which checks the extension the given filename.- Parameters:
filename- the file name- Returns:
trueif the given file name ends with one of the registered extensions,falseotherwise.
-
checkExtensions
Utility method which checks the extension the given filename.- Parameters:
filename- the file nameextensions- the extension- Returns:
trueif the given file name ends with one of the registered extensions,falseotherwise.
-
accept
Tests whether or not the given file is accepted by this filter. The default implementation returnstrueif the given file is a directory or the path string ends with one of the registered extensions. if no extension are defined, the method always returnstrue- Specified by:
acceptin classFileFilter- Parameters:
file- the file to be or not be accepted.- Returns:
trueif given file is accepted by this filter
-
isCompoundDocument
Checks if the given directory represents a compound document. If so, we don't want the user to descend into it when using theJFileChooser. The default implementation returnsfalse. Clients may override.- Parameters:
dir- The directory to check.- Returns:
trueIf the given directory represents a compound document.- Since:
- BEAM 4.6.1
-
getFileSelectionMode
Gets the file selection mode for theJFileChooserif this filter is used. The default implementation returnsSnapFileFilter.FileSelectionMode.FILES_ONLY. Clients may override.- Returns:
trueif the user can also select directories using this filter.- Since:
- BEAM 4.6.1
-
getSortedFileFilters
public static <T extends ProductIOPlugIn> List<SnapFileFilter> getSortedFileFilters(Iterator<T> pluginIterator) Return a alphabetically sorted list of file filters originating from a productIO plugin iterator.- Parameters:
pluginIterator- a productIO plugin iterator- Returns:
- a sorted list of file filters
- Since:
- BEAM 4.10
-