org.clapper.util.io
Class RegexFileFilter
- java.lang.Object
-
- org.clapper.util.io.RegexFileFilter
-
- All Implemented Interfaces:
- java.io.FileFilter
public class RegexFileFilter extends java.lang.Object implements java.io.FileFilterRegexFileFilter implements a java.io.FileFilter class that matches files using a regular expression. Multiple regular expression filters can be combined using
AndFileFilterand/orOrFileFilterobjects.A RegexFileFilter can be configured to operate on just the simple file name, or on the file's path.
RegexFileFilter uses the java.util.regex regular expression classes.
- See Also:
AndFileFilter,OrFileFilter,NotFileFilter,RegexFilenameFilter
-
-
Constructor Summary
Constructors Constructor and Description RegexFileFilter(java.lang.String regex, FileFilterMatchType matchType)Construct a new RegexFileFilter using the specified pattern.RegexFileFilter(java.lang.String regex, int regexFlags, FileFilterMatchType matchType)Construct a new RegexFileFilter using the specified pattern.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description booleanaccept(java.io.File file)Determine whether a file is to be accepted or not, based on the regular expressions in the reject and accept lists.
-
-
-
Constructor Detail
-
RegexFileFilter
public RegexFileFilter(java.lang.String regex, FileFilterMatchType matchType) throws java.util.regex.PatternSyntaxExceptionConstruct a new RegexFileFilter using the specified pattern.- Parameters:
regex- the regular expression to addmatchType- FileFilterMatchType.FILENAME to match just the filename, FileFilterMatchType.PATH to match the path (via java.io.File.getPath())- Throws:
java.util.regex.PatternSyntaxException- bad regular expression
-
RegexFileFilter
public RegexFileFilter(java.lang.String regex, int regexFlags, FileFilterMatchType matchType) throws java.util.regex.PatternSyntaxExceptionConstruct a new RegexFileFilter using the specified pattern.- Parameters:
regex- the regular expression to addregexFlags- regular expression compilation flags (e.g., Pattern.CASE_INSENSITIVE). See the Javadocs for java.util.regex for legal values.matchType- FileFilterMatchType.FILENAME to match just the filename, FileFilterMatchType.PATH to match the path (via java.io.File.getPath())- Throws:
java.util.regex.PatternSyntaxException- bad regular expression
-
-
Method Detail
-
accept
public boolean accept(java.io.File file)
Determine whether a file is to be accepted or not, based on the regular expressions in the reject and accept lists.- Specified by:
acceptin interfacejava.io.FileFilter- Parameters:
file- The file to test. If the match type is FileFilterMatchType.FILENAME, then the value of file.getPath() is compared to the regular expression. If the match type is FileFilterMatchType.PATH, then the value of file.getName() is compared to the regular expression.- Returns:
- true if the file matches, false if it doesn't
-
-
DMelt 3.0 © DataMelt by jWork.ORG