com.cometway.io
Class RegExpFilenameFilter
java.lang.Object
com.cometway.io.RegExpFilenameFilter
- All Implemented Interfaces:
- java.io.FilenameFilter
public class RegExpFilenameFilter
- extends java.lang.Object
- implements java.io.FilenameFilter
This class is an implementation of java.io.FilenameFilter using
the JDK regular expression package to either include or exclude
all files matching the expression.
|
Field Summary |
protected boolean |
exclude
|
protected java.lang.String |
regexp
|
|
Constructor Summary |
RegExpFilenameFilter(java.lang.String regexp)
Creates a FilenameFilter that accepts files matching
the specified regular expression. |
RegExpFilenameFilter(java.lang.String regexp,
boolean exclude)
Creates a FilenameFilter that filters files based on
the specified regular expression. |
|
Method Summary |
boolean |
accept(java.io.File dir,
java.lang.String name)
Returns true if the file should be included in a file list. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
regexp
protected java.lang.String regexp
exclude
protected boolean exclude
RegExpFilenameFilter
public RegExpFilenameFilter(java.lang.String regexp)
- Creates a FilenameFilter that accepts files matching
the specified regular expression.
- Parameters:
regexp - is the regular expression matched against filenames.
RegExpFilenameFilter
public RegExpFilenameFilter(java.lang.String regexp,
boolean exclude)
- Creates a FilenameFilter that filters files based on
the specified regular expression.
- Parameters:
regexp - is the regular expression matched against filenames.exclude - if true matching files will not be accepted;
if false matching files will be accepted.
accept
public boolean accept(java.io.File dir,
java.lang.String name)
- Returns true if the file should be included in a file list.
If exclude is false, returns true if name matches the regular expression.
If exclude is true, returns false if name matches the regular expression.
This switchable behavior allows for two different filtering models.
- Specified by:
accept in interface java.io.FilenameFilter