de.jstacs.io
Class RegExFilenameFilter
java.lang.Object
javax.swing.filechooser.FileFilter
de.jstacs.io.RegExFilenameFilter
- All Implemented Interfaces:
- FileFilter, FilenameFilter
public class RegExFilenameFilter
- extends FileFilter
- implements FileFilter, FilenameFilter
A simple filter on File
s that accepts File
s with a specific regular expression
in the filename.
- Author:
- Jens Keilwagen
- See Also:
String.matches(String)
,
Pattern
RegExFilenameFilter
public RegExFilenameFilter(String desc,
RegExFilenameFilter.Directory dir,
boolean ignoreCase,
String... regex)
- Creates a new
RegExFilenameFilter
with given
regular expressions regex
to be found in the
file name of the File
s to be filtered.
- Parameters:
desc
- the description of the filter, e.g. "text-files
(*.txt)"dir
- a switch whether the results are forbidden, allowed or required to be a directoryignoreCase
- indicates whether to ignore the case of the file names or notregex
- an array of regular expressions; at least one regular expression has to match
the file name
accept
public boolean accept(File arg0)
- Specified by:
accept
in interface FileFilter
- Specified by:
accept
in class FileFilter
accept
public boolean accept(File dir,
String name)
- Specified by:
accept
in interface FilenameFilter
getDescription
public String getDescription()
- Specified by:
getDescription
in class FileFilter
getRegEx
public String getRegEx()
- Returns a representation of all used regular expressions.
- Returns:
- a representation of all used regular expressions
toString
public String toString()
- Overrides:
toString
in class Object