Class FileNameRegexFilter

java.lang.Object
javax.swing.filechooser.FileFilter
adalid.util.io.FileNameRegexFilter

public class FileNameRegexFilter extends FileFilter
Author:
Jorge Campins
  • Constructor Details

    • FileNameRegexFilter

      public FileNameRegexFilter(String description, String regex)
      Creates a FileNameRegexFilter with the specified description and regular expression. The returned FileNameRegexFilter will accept all directories and any file with a file name matching regex.
      Parameters:
      description - textual description for the filter, may be null
      regex - the accepted file name regular expression
      Throws:
      IllegalArgumentException - if regex is null
      PatternSyntaxException - if regex's syntax is invalid
      See Also:
    • FileNameRegexFilter

      public FileNameRegexFilter(String description, String regex, boolean dirs)
      Creates a FileNameRegexFilter with the specified description and regular expression. The returned FileNameRegexFilter will accept all directories and any file with a file name matching regex.
      Parameters:
      description - textual description for the filter, may be null
      regex - the accepted file name regular expression
      dirs - true if directories are to be accepted
      Throws:
      IllegalArgumentException - if regex is null
      PatternSyntaxException - if regex's syntax is invalid
      See Also:
  • Method Details

    • accept

      public boolean accept(File f)
      Tests the specified file, returning true if it is a directory and directories are to be accepted, or its name matches the regular expression of this FileFilter.
      Specified by:
      accept in class FileFilter
      Parameters:
      f - the File to test
      Returns:
      true if the file is to be accepted, false otherwise
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in class FileFilter
      Returns:
      the description of this filter
    • getPattern

      public Pattern getPattern()
      Returns:
      the regular expression files are tested against
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      a string representation of this FileNameRegexFilter