de.caff.gimmicks.swing

## Class SimpleFileExtensionFilter

- java.lang.Object
- - javax.swing.filechooser.FileFilter
  - - de.caff.gimmicks.swing.SimpleFileExtensionFilter

-     public class SimpleFileExtensionFilter
      extends javax.swing.filechooser.FileFilter

  A simple file filter for the Swing file chooser allowing only files with a certain extension.
  Author:
    Rammi

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SimpleFileExtensionFilter(java.lang.String extension)` Create a file filter with a default name.
    `SimpleFileExtensionFilter(java.lang.String extension, java.lang.String description)` Create a file filter.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `accept(java.io.File f)` Whether the given file is accepted by this filter.
    `java.lang.String` | `getDescription()` The description of this filter.
    `java.io.File` | `getFixedFilePath(java.io.File file)` Add the extension to a path if it does not already end with it and the file is non-existent.
    `java.lang.String` | `getFixedPath(java.io.File file)` Add the extension to a path if it does not already end with it and the file is non-existent.
    `boolean` | `isAllowDirectories()` Are directories allowed by this filter?
    `void` | `setAllowDirectories(boolean allowDirectories)` Set whether directories are allowed by this filter.

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

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

- - ### Constructor Detail

    - #### SimpleFileExtensionFilter

          public SimpleFileExtensionFilter(@NotNull
                                           java.lang.String extension)

      Create a file filter with a default name.
      Parameters:
        `extension` - the extension to look for

    - #### SimpleFileExtensionFilter

          public SimpleFileExtensionFilter(@NotNull
                                           java.lang.String extension,
                                           @NotNull
                                           java.lang.String description)

      Create a file filter.
      Parameters:
        `extension` - the extension to look for
        `description` - description of this filter

  - ### Method Detail

    - #### getDescription

          @NotNull
          public java.lang.String getDescription()

      The description of this filter. For example: "JPEG Images"
      Specified by:
        `getDescription` in class `javax.swing.filechooser.FileFilter`
      See Also:
        `FileView.getName(java.io.File)`

    - #### accept

          public boolean accept(java.io.File f)

      Whether the given file is accepted by this filter.
      Specified by:
        `accept` in class `javax.swing.filechooser.FileFilter`

    - #### isAllowDirectories

          public boolean isAllowDirectories()

      Are directories allowed by this filter?
      Returns:
        the answer

    - #### setAllowDirectories

          public void setAllowDirectories(boolean allowDirectories)

      Set whether directories are allowed by this filter.
      Parameters:
        `allowDirectories` - allow directories?

    - #### getFixedPath

          @NotNull
          public java.lang.String getFixedPath(@NotNull
                                                        java.io.File file)

      Add the extension to a path if it does not already end with it and the file is non-existent.
      Parameters:
        `file` - fle which paths is needed
      Returns:
        path including the extension

    - #### getFixedFilePath

          @NotNull
          public java.io.File getFixedFilePath(@NotNull
                                                        java.io.File file)

      Add the extension to a path if it does not already end with it and the file is non-existent.
      Parameters:
        `file` - fle which paths is needed
      Returns:
        path including the extension