org.clapper.util.io
Class RegexFilenameFilter
- java.lang.Object
-
- org.clapper.util.io.RegexFilenameFilter
-
- All Implemented Interfaces:
- java.io.FilenameFilter
public class RegexFilenameFilter extends java.lang.Object implements java.io.FilenameFilterRegexFilenameFilter implements a java.io.FilenameFilter class that matches files using a regular expression. Multiple regular expression filters can be combined using
AndFilenameFilterand/orOrFilenameFilterobjects.A RegexFilenameFilter can be configured to operate on just the simple file name, or on the file's path.
RegexFilenameFilter uses the java.util.regex regular expression classes.
-
-
Constructor Summary
Constructors Constructor and Description RegexFilenameFilter(java.lang.String regex)Construct a new RegexFilenameFilter using the specified pattern, with an implied match type of FileFilterMatchType.FILENAME.RegexFilenameFilter(java.lang.String regex, FileFilterMatchType matchType)Construct a new RegexFilenameFilter using the specified pattern.RegexFilenameFilter(java.lang.String regex, int regexFlags, FileFilterMatchType matchType)Construct a new RegexFilenameFilter using the specified pattern.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description booleanaccept(java.io.File dir, java.lang.String name)Determine whether a file is to be accepted or not, based on the regular expressions in the reject and accept lists.
-
-
-
Constructor Detail
-
RegexFilenameFilter
public RegexFilenameFilter(java.lang.String regex) throws java.util.regex.PatternSyntaxExceptionConstruct a new RegexFilenameFilter using the specified pattern, with an implied match type of FileFilterMatchType.FILENAME.- Parameters:
regex- the regular expression to add- Throws:
java.util.regex.PatternSyntaxException- bad regular expression
-
RegexFilenameFilter
public RegexFilenameFilter(java.lang.String regex, FileFilterMatchType matchType) throws java.util.regex.PatternSyntaxExceptionConstruct a new RegexFilenameFilter 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
-
RegexFilenameFilter
public RegexFilenameFilter(java.lang.String regex, int regexFlags, FileFilterMatchType matchType) throws java.util.regex.PatternSyntaxExceptionConstruct a new RegexFilenameFilter 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 dir, java.lang.String name)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.FilenameFilter- Parameters:
dir- The directory containing the file. Ignored if the match type is FileFilterMatchType.FILENAME. Used to build the path to match when the match type is FileFilterMatchType.PATHname- the file name- Returns:
- true if the file matches, false if it doesn't
-
-
DMelt 3.0 © DataMelt by jWork.ORG