Class FileNameRegexFilter


  • public class FileNameRegexFilter
    extends javax.swing.filechooser.FileFilter
    Author:
    Jorge Campins
    • Constructor Summary

      Constructors 
      Constructor Description
      FileNameRegexFilter​(java.lang.String description, java.lang.String regex)
      Creates a FileNameRegexFilter with the specified description and regular expression.
      FileNameRegexFilter​(java.lang.String description, java.lang.String regex, boolean dirs)
      Creates a FileNameRegexFilter with the specified description and regular expression.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean accept​(java.io.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.
      java.lang.String getDescription()  
      java.util.regex.Pattern getPattern()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • FileNameRegexFilter

        public FileNameRegexFilter​(java.lang.String description,
                                   java.lang.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:
        java.lang.IllegalArgumentException - if regex is null
        java.util.regex.PatternSyntaxException - if regex's syntax is invalid
        See Also:
        accept(java.io.File)
      • FileNameRegexFilter

        public FileNameRegexFilter​(java.lang.String description,
                                   java.lang.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:
        java.lang.IllegalArgumentException - if regex is null
        java.util.regex.PatternSyntaxException - if regex's syntax is invalid
        See Also:
        accept(java.io.File)
    • Method Detail

      • accept

        public boolean accept​(java.io.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 javax.swing.filechooser.FileFilter
        Parameters:
        f - the File to test
        Returns:
        true if the file is to be accepted, false otherwise
      • getDescription

        public java.lang.String getDescription()
        Specified by:
        getDescription in class javax.swing.filechooser.FileFilter
        Returns:
        the description of this filter
      • getPattern

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

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