dfs 01/03/29 09:19:13
Modified: src/java/org/apache/oro/io RegexFilenameFilter.java
Log:
Added Dan Lipofsky's suggested enhancement to implement the Java 1.1
FileFilter interface.
Revision Changes Path
1.3 +19 -2 jakarta-oro/src/java/org/apache/oro/io/RegexFilenameFilter.java
Index: RegexFilenameFilter.java
===================================================================
RCS file: /home/cvs/jakarta-oro/src/java/org/apache/oro/io/RegexFilenameFilter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RegexFilenameFilter.java 2000/07/23 23:25:14 1.2
+++ RegexFilenameFilter.java 2001/03/29 17:19:11 1.3
@@ -67,13 +67,15 @@
* implementations that filter based on a regular expression.
@author <a href="mailto:[EMAIL PROTECTED]">Daniel F. Savarese</a>
- @version $Id: RegexFilenameFilter.java,v 1.2 2000/07/23 23:25:14 jon Exp $
+ @version $Id: RegexFilenameFilter.java,v 1.3 2001/03/29 17:19:11 dfs Exp $
* @see Perl5FilenameFilter
* @see AwkFilenameFilter
* @see GlobFilenameFilter
*/
-public abstract class RegexFilenameFilter implements FilenameFilter {
+public abstract class RegexFilenameFilter implements FilenameFilter,
+ FileFilter
+ {
PatternCache _cache;
PatternMatcher _matcher;
Pattern _pattern;
@@ -135,6 +137,7 @@
/**
* Filters a filename. Tests if the filename EXACTLY matches the pattern
* contained by the filter. The directory argument is not examined.
+ * Conforms to the java.io.FilenameFilter interface.
* <p>
* @param dir The directory containing the file.
* @param filename The name of the file.
@@ -143,6 +146,20 @@
public boolean accept(File dir, String filename) {
synchronized(_matcher) {
return _matcher.matches(filename, _pattern);
+ }
+ }
+
+ /**
+ * Filters a filename. Tests if the filename EXACTLY matches the pattern
+ * contained by the filter. The filename is defined as pathname.getName().
+ * Conforms to the java.io.FileFilter interface.
+ * <p>
+ * @param pathname The file pathname.
+ * @return True if the filename EXACTLY matches the pattern, false if not.
+ */
+ public boolean accept(File pathname) {
+ synchronized(_matcher) {
+ return _matcher.matches(pathname.getName(), _pattern);
}
}
}