Class MultiExtFileFilter

java.lang.Object
javax.swing.filechooser.FileFilter
fr.esrf.tangoatk.widget.util.MultiExtFileFilter

public class MultiExtFileFilter extends FileFilter
A file filter that can accept multiple extensions (as for jpg, jpe, jpeg). The description is automatically computed with the prefix followed by the list of extensions.
Author:
MAINGUY
  • Field Details

    • prefix

      protected String prefix
    • extensions

      protected List<String> extensions
    • description

      protected String description
  • Constructor Details

    • MultiExtFileFilter

      public MultiExtFileFilter(String filterDescription, String defaultExtension, String... otherExtensions)
      Parameters:
      filterDescription - the description of the type of accepted files
      defaultExtension - a default extension. It ensures we have at least one extension.
      otherExtensions - more extensions for this type of files
  • Method Details

    • accept

      public boolean accept(File f)
      Specified by:
      accept in class FileFilter
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in class FileFilter
    • isAccepted

      public boolean isAccepted(String fileExtension)
      Return true if the specified extension is accepted by the filter.
      Parameters:
      fileExtension - the fileExtension to test
      Returns:
      true if the filter would accept this extension, false otherwise or if the extension is null
    • getDefaultExtension

      public String getDefaultExtension()
      Return the default extension. It can be useful when saving a file whose filename has no extension specified.
      Returns:
      the default extension.
    • computeDescription

      protected void computeDescription()
      Compute the whole description for the filter. User description is followed by allowed extensions as a list.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getExtension

      public static String getExtension(File f)
      returns the extension of a given file, that is the part after the last '.' in the filename. Result is in lower case.
      Parameters:
      f - the file
      Returns:
      the extension if any, null otherwise