Package adalid.util.io
Class FileNameRegexFilter
- java.lang.Object
-
- javax.swing.filechooser.FileFilter
-
- adalid.util.io.FileNameRegexFilter
-
public class FileNameRegexFilter extends FileFilter
- Author:
- Jorge Campins
-
-
Constructor Summary
Constructors Constructor Description FileNameRegexFilter(String description, String regex)Creates aFileNameRegexFilterwith the specified description and regular expression.FileNameRegexFilter(String description, 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(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.StringgetDescription()PatterngetPattern()StringtoString()
-
-
-
Constructor Detail
-
FileNameRegexFilter
public FileNameRegexFilter(String description, 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:
IllegalArgumentException- if regex is nullPatternSyntaxException- if regex's syntax is invalid- See Also:
accept(java.io.File)
-
FileNameRegexFilter
public FileNameRegexFilter(String description, 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:
IllegalArgumentException- if regex is nullPatternSyntaxException- if regex's syntax is invalid- See Also:
accept(java.io.File)
-
-
Method Detail
-
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 thisFileFilter.- Specified by:
acceptin classFileFilter- Parameters:
f- theFileto test- Returns:
- true if the file is to be accepted, false otherwise
-
getDescription
public String getDescription()
- Specified by:
getDescriptionin classFileFilter- Returns:
- the description of this filter
-
getPattern
public Pattern getPattern()
- Returns:
- the regular expression files are tested against
-
-