1 package org.apache.oro.io; 2 3 59 60 import java.io.*; 61 62 import org.apache.oro.text.regex.*; 63 import org.apache.oro.text.*; 64 65 76 public abstract class RegexFilenameFilter implements FilenameFilter { 77 PatternCache _cache; 78 PatternMatcher _matcher; 79 Pattern _pattern; 80 81 RegexFilenameFilter(PatternCache cache, PatternMatcher matcher, String regex) 82 { 83 _cache = cache; 84 _matcher = matcher; 85 setFilterExpression(regex); 86 } 87 88 RegexFilenameFilter(PatternCache cache, PatternMatcher matcher, 89 String regex, int options) 90 { 91 _cache = cache; 92 _matcher = matcher; 93 setFilterExpression(regex); 94 } 95 96 RegexFilenameFilter(PatternCache cache, PatternMatcher matcher) { 97 this(cache, matcher, ""); 98 } 99 100 110 public void setFilterExpression(String regex) 111 throws MalformedCachePatternException 112 { 113 _pattern = _cache.getPattern(regex); 114 } 115 116 129 public void setFilterExpression(String regex, int options) 130 throws MalformedCachePatternException 131 { 132 _pattern = _cache.getPattern(regex, options); 133 } 134 135 143 public boolean accept(File dir, String filename) { 144 synchronized(_matcher) { 145 return _matcher.matches(filename, _pattern); 146 } 147 } 148 } 149 | Popular Tags |