Package adalid.util.io
Class FileNameRegexFilter
- java.lang.Object
-
- javax.swing.filechooser.FileFilter
-
- adalid.util.io.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 aFileNameRegexFilterwith the specified description and regular expression.FileNameRegexFilter(java.lang.String description, java.lang.String regex, boolean dirs)Creates aFileNameRegexFilterwith the specified description and regular expression.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccept(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 thisFileFilter.java.lang.StringgetDescription()java.util.regex.PatterngetPattern()java.lang.StringtoString()
-
-
-
Constructor Detail
-
FileNameRegexFilter
public FileNameRegexFilter(java.lang.String description, java.lang.String regex)Creates aFileNameRegexFilterwith the specified description and regular expression. The returnedFileNameRegexFilterwill accept all directories and any file with a file name matchingregex.- Parameters:
description- textual description for the filter, may benullregex- the accepted file name regular expression- Throws:
java.lang.IllegalArgumentException- if regex is nulljava.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 aFileNameRegexFilterwith the specified description and regular expression. The returnedFileNameRegexFilterwill accept all directories and any file with a file name matchingregex.- Parameters:
description- textual description for the filter, may benullregex- the accepted file name regular expressiondirs- true if directories are to be accepted- Throws:
java.lang.IllegalArgumentException- if regex is nulljava.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 thisFileFilter.- Specified by:
acceptin classjavax.swing.filechooser.FileFilter- Parameters:
f- theFileto test- Returns:
- true if the file is to be accepted, false otherwise
-
getDescription
public java.lang.String getDescription()
- Specified by:
getDescriptionin classjavax.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:
toStringin classjava.lang.Object- Returns:
- a string representation of this
FileNameRegexFilter
-
-