Class SnapFileFilter

java.lang.Object
javax.swing.filechooser.FileFilter
org.esa.snap.core.util.io.SnapFileFilter
Direct Known Subclasses:
DimapFileFilter

public class SnapFileFilter extends FileFilter
A FileFilter with file extensions support.
  • Constructor Details

    • SnapFileFilter

      public SnapFileFilter()
    • SnapFileFilter

      public SnapFileFilter(String formatName, String extension, String description)
    • SnapFileFilter

      public SnapFileFilter(String formatName, String[] extensions, String description)
  • Method Details

    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getFormatName

      public String getFormatName()
    • setFormatName

      public void setFormatName(String formatName)
    • hasExtensions

      public boolean hasExtensions()
      Returns whether or not this file filter has extensions.
      Returns:
      true if so
    • getDefaultExtension

      public String getDefaultExtension()
      Returns the default extension. The default extension is the first entry in the array returned by the getExtensions method.
      Returns:
      the default extension or null if no extensions have bees specified.
      See Also:
    • getExtensions

      public String[] getExtensions()
      Returns the accepted extensions of this filter. For example: {".jpg", ".gif", ".png"}.
      Returns:
      The array of extensions.
      See Also:
    • setExtensions

      public void setExtensions(String[] extensions)
      Sets the accepted extensions of this filter. For example: {".jpg", ".gif", ".png"}.
      Parameters:
      extensions - The array of extensions.
      See Also:
    • getDescription

      public String getDescription()
      Returns the description of this filter. For example: "JPEG Images (*.jpg,*.jpeg)".
      Specified by:
      getDescription in class FileFilter
      See Also:
    • setDescription

      public void setDescription(String description)
      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

      public boolean checkExtension(File file)
      Utility method which checks the extension the given file.
      Parameters:
      file - the file
      Returns:
      true if the given file path ends with one of the registered extensions, false otherwise.
    • checkExtension

      public boolean checkExtension(String filename)
      Utility method which checks the extension the given filename.
      Parameters:
      filename - the file name
      Returns:
      true if the given file name ends with one of the registered extensions, false otherwise.
    • checkExtensions

      public static boolean checkExtensions(String filename, String[] extensions)
      Utility method which checks the extension the given filename.
      Parameters:
      filename - the file name
      extensions - the extension
      Returns:
      true if the given file name ends with one of the registered extensions, false otherwise.
    • accept

      public boolean accept(File file)
      Tests whether or not the given file is accepted by this filter. The default implementation returns true if 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 returns true
      Specified by:
      accept in class FileFilter
      Parameters:
      file - the file to be or not be accepted.
      Returns:
      true if given file is accepted by this filter
    • isCompoundDocument

      public boolean isCompoundDocument(File dir)
      Checks if the given directory represents a compound document. If so, we don't want the user to descend into it when using the JFileChooser. The default implementation returns false. Clients may override.
      Parameters:
      dir - The directory to check.
      Returns:
      true If the given directory represents a compound document.
      Since:
      BEAM 4.6.1
    • getFileSelectionMode

      public SnapFileFilter.FileSelectionMode getFileSelectionMode()
      Gets the file selection mode for the JFileChooser if this filter is used. The default implementation returns SnapFileFilter.FileSelectionMode.FILES_ONLY. Clients may override.
      Returns:
      true if 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