Package ghidra.util.filechooser

# Class ExtensionFileFilter

java.lang.Object
ghidra.util.filechooser.ExtensionFileFilter

All Implemented Interfaces:
  `GhidraFileFilter`

public class ExtensionFileFilter extends Object implements GhidraFileFilter
A convenience implementation of FileFilter that filters out all files except for those type extensions that it knows about.

Extensions are of the type "foo" (no leading dot). Case is ignored.

Example - create a new filter that filters out all files but gif and jpg image files:

         GhidraFileChooser chooser = new GhidraFileChooser();
         chooser.addFileFilter(ExtensionFilFilter.forExtensions("JPEG and GIF Images", "gif", "jpg"));

- ## Field Summary

  ### Fields inherited from interface ghidra.util.filechooser.GhidraFileFilter

  `ALL`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ExtensionFileFilter(String[] filters, String description)`
  Creates a file filter from the given string array and description.
  `ExtensionFileFilter(String extension, String description)`
  Creates a file filter that accepts the given file type.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `accept(File f, GhidraFileChooserModel model)`
  Return true if this file should be shown in the directory pane, false if it shouldn't.
  `static ExtensionFileFilter`
  `forExtensions(String description, String... exts)`
  Creates a `ExtensionFileFilter` in a varargs friendly way.
  `String`
  `getDescription()`
  Returns the description of this filter.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ExtensionFileFilter

    public ExtensionFileFilter(String extension, String description)
    Creates a file filter that accepts the given file type. Example: new ExtensionFileFilter("jpg", "JPEG Images");
    Parameters:
      `extension` - file extension to match, without leading dot
      `description` - descriptive string of the filter

  - ### ExtensionFileFilter

    public ExtensionFileFilter(String[] filters, String description)
    Creates a file filter from the given string array and description. Example: new ExtensionFileFilter(String {"gif", "jpg"}, "Gif and JPG Images");
    Parameters:
      `filters` - array of file name extensions, each without a leading dot
      `description` - descriptive string of the filter

- ## Method Details

  - ### forExtensions

    public static ExtensionFileFilter forExtensions(String description, String... exts)
    Creates a `ExtensionFileFilter` in a varargs friendly way.
    Parameters:
      `description` - String description of this set of file extensions.
      `exts` - variable length list of file extensions, without leading dot.
    Returns:
      new `ExtensionFileFilter` instance.

  - ### accept

    public boolean accept(File f, GhidraFileChooserModel model)
    Return true if this file should be shown in the directory pane, false if it shouldn't. Files that begin with "." are ignored.
    Specified by:
      `accept` in interface `GhidraFileFilter`
    Parameters:
      `f` - The abstract pathname to be tested
      `model` - The underlying file chooser model
    Returns:
      `true` if and only if `pathname` should be included
    See Also:
      - `FileFilter.accept(java.io.File)`

  - ### getDescription

    public String getDescription()
    Description copied from interface: `GhidraFileFilter`
    Returns the description of this filter.
    Specified by:
      `getDescription` in interface `GhidraFileFilter`
    Returns:
      the description of this filter