Class ExtensionFileFilter

java.lang.Object
com.sun.interview.ExtensionFileFilter
All Implemented Interfaces:
FileFilter

public class ExtensionFileFilter extends Object implements FileFilter
A filter which accepts files based on their extension.
  • Constructor Details

    • ExtensionFileFilter

      public ExtensionFileFilter(String extn, String description)
      Create a filter which accepts files based on their extension.
      Parameters:
      extn - The required extension for files that are to be accepted by this filter.
      description - A short string describing the filter.
    • ExtensionFileFilter

      public ExtensionFileFilter(String[] extns, String description)
      Create a filter which accepts files based on their extension.
      Parameters:
      extns - Any array of permissible extensions for files that are to be accepted by this filter.
      description - A short string describing the filter.
  • Method Details

    • isCaseSensitive

      public boolean isCaseSensitive()
      Check whether or not this filter should perform case-sensitive matching for extensions.
      Returns:
      true if this filter should perform case-sensitive matching for extensions, and false otherwise
      See Also:
    • setCaseSensitive

      public void setCaseSensitive(boolean b)
      Specify whether or not this filter should perform case-sensitive matching for extensions.
      Parameters:
      b - true if this filter should perform case-sensitive matching for extensions, and false otherwise
      See Also:
    • accept

      public boolean accept(File f)
      Description copied from interface: FileFilter
      Check if a file is accepted by this filter.
      Specified by:
      accept in interface FileFilter
      Parameters:
      f - The file to be tested.
      Returns:
      true if the file is accepted by this filter
    • acceptsDirectories

      public boolean acceptsDirectories()
      Description copied from interface: FileFilter
      Check if (all) directories are accepted by this filter.
      Specified by:
      acceptsDirectories in interface FileFilter
      Returns:
      true if directories are accepted by this filter
    • getDescription

      public String getDescription()
      Get a short description for this filter.
      Specified by:
      getDescription in interface FileFilter
      Returns:
      a short description of this filter
    • ensureExtension

      public String ensureExtension(String path)
      Ensure that a pathname ends with one of the extensions accepted by this filter. If it does not, one is appended
      Parameters:
      path - The path to be checked.
      Returns:
      the original path if it already ended with a valid extension, or if it was null or empty; otherwise, a copy of the path is returned, with a valid extension added on.
    • ensureExtension

      public File ensureExtension(File file)
      Ensure that a filename ends with one of the extensions accepted by this filter. If it does not, one is appended
      Parameters:
      file - The file to be checked.
      Returns:
      the original file if it already ended with a valid extension, or if it was null or empty; otherwise, a new file is returned, whose path is a copy of the original, with a valid extension added on.