jodd.io.findfile.RegExpFindFile Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jodd-core Show documentation
Show all versions of jodd-core Show documentation
Jodd Core tools and utilities, including type converters, JDateTime, cache etc.
// Copyright (c) 2003-2014, Jodd Team (jodd.org). All Rights Reserved.
package jodd.io.findfile;
import java.util.HashMap;
import java.util.regex.Pattern;
/**
* Simple {@link FindFile} that matches file names with regular expression pattern.
* @see jodd.io.findfile.WildcardFindFile
*/
public class RegExpFindFile extends FindFile {
private HashMap searchPatterns;
@Override
protected boolean match(String path, String patternString) {
if (searchPatterns == null) {
searchPatterns = new HashMap();
}
Pattern pattern = searchPatterns.get(patternString);
if (pattern == null) {
pattern = Pattern.compile(patternString);
searchPatterns.put(patternString, pattern);
}
return pattern.matcher(path).matches();
}
}