All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jodd.io.findfile.RegExpFindFile Maven / Gradle / Ivy

Go to download

Jodd Core tools and utilities, including type converters, JDateTime, cache etc.

There is a newer version: 5.3.0
Show newest version
// 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();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy