Class SnapFileFilter

  • Direct Known Subclasses:
    DimapFileFilter

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

      • SnapFileFilter

        public SnapFileFilter()
      • SnapFileFilter

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

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

      • 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()
      • getExtensions

        public String[] getExtensions()
        Returns the accepted extensions of this filter. For example: {".jpg", ".gif", ".png"}.
        Returns:
        The array of extensions.
        See Also:
        setExtensions(java.lang.String[])
      • 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:
        getExtensions()
      • 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:
        getDescription()
      • 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
      • getSortedFileFilters

        public static <T extends ProductIOPlugInList<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