1 package jodd.file.filters; 2 3 import java.io.File; 4 import java.io.FileFilter; 5 import java.util.regex.Matcher; 6 import java.util.regex.Pattern; 7 8 import jodd.util.StringFlags; 9 import jodd.util.StringUtil; 10 11 24 public class RegExpFileFilter extends FileFilterAbs { 25 26 28 31 public RegExpFileFilter(String pattern, String opt) { 32 super(pattern, opt); 33 } 34 35 40 public RegExpFileFilter(String pattern) { 41 super(pattern); 42 } 43 44 48 public RegExpFileFilter() { 49 super(); 50 } 51 52 54 private Pattern regexpPattern = null; 55 56 62 public void setPattern(String p) { 63 super.setPattern(p); 64 if (pattern != null) { 65 regexpPattern = Pattern.compile(pattern); 66 } 67 } 68 69 71 79 public boolean match(File file) { 80 Matcher matcher = regexpPattern.matcher(getFileName(file)); return matcher.matches(); 82 } 83 } 84 85 | Popular Tags |