本文整理匯總了Java中org.springframework.util.PathMatcher.match方法的典型用法代碼示例。如果您正苦於以下問題:Java PathMatcher.match方法的具體用法?Java PathMatcher.match怎麽用?Java PathMatcher.match使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.util.PathMatcher
的用法示例。
在下文中一共展示了PathMatcher.match方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isAllowed
import org.springframework.util.PathMatcher; //導入方法依賴的package包/類
private boolean isAllowed(String resourcePath) {
if (resourcePath.matches(PROTECTED_PATH)) {
return false;
}
PathMatcher pathMatcher = new AntPathMatcher();
for (String pattern : allowedResourcePaths) {
if (pathMatcher.match(pattern, resourcePath)) {
return true;
}
}
return false;
}
示例2: match
import org.springframework.util.PathMatcher; //導入方法依賴的package包/類
@Override
public boolean match(String url, PathMatcher pathMatcher) {
return pathMatcher.match(urlMatcher, url);
}
示例3: hasMatch
import org.springframework.util.PathMatcher; //導入方法依賴的package包/類
private boolean hasMatch(PathMatcher pathMatcher, String path,
List<String> patterns) {
for (String pattern : patterns) {
if (pathMatcher.match(pattern, path)) {
return true;
}
}
return false;
}
示例4: isAllowed
import org.springframework.util.PathMatcher; //導入方法依賴的package包/類
private boolean isAllowed(String resourcePath) {
if (resourcePath.matches(PROTECTED_PATH)) {
return false;
}
PathMatcher pathMatcher = new AntPathMatcher();
for (String pattern : (allowedResourcePaths == null ? ALLOWED_RESOURCE_PATHS : allowedResourcePaths)) {
if (pathMatcher.match(pattern, resourcePath)) {
return true;
}
}
return false;
}
示例5: findImportedBundleMatchingResource
import org.springframework.util.PathMatcher; //導入方法依賴的package包/類
/**
* Searches for the given pattern inside the imported bundle. This translates to pattern matching on the imported
* packages.
*
* @param importedBundle imported bundle
* @param path path used for pattern matching
* @param foundPaths collection of found results
*/
@SuppressWarnings("unchecked")
private void findImportedBundleMatchingResource(final ImportedBundle importedBundle, String rootPath, String path,
final Collection<String> foundPaths) throws IOException {
final boolean trace = logger.isTraceEnabled();
String[] packages = importedBundle.getImportedPackages();
if (trace)
logger.trace("Searching path [" + path + "] on imported pkgs " + ObjectUtils.nullSafeToString(packages)
+ "...");
final boolean startsWithSlash = rootPath.startsWith(FOLDER_SEPARATOR);
for (int i = 0; i < packages.length; i++) {
// transform the package name into a path
String pkg = packages[i].replace(DOT, SLASH) + SLASH;
if (startsWithSlash) {
pkg = FOLDER_SEPARATOR + pkg;
}
final PathMatcher matcher = getPathMatcher();
// if the imported package matches the path
if (matcher.matchStart(path, pkg)) {
Bundle bundle = importedBundle.getBundle();
// 1. look at the Bundle jar root
Enumeration<String> entries = bundle.getEntryPaths(pkg);
while (entries != null && entries.hasMoreElements()) {
String entry = entries.nextElement();
if (startsWithSlash)
entry = FOLDER_SEPARATOR + entry;
if (matcher.match(path, entry)) {
if (trace)
logger.trace("Found entry [" + entry + "]");
foundPaths.add(entry);
}
}
// 2. Do a Bundle-Classpath lookup (since the jar might use a different classpath)
Collection<String> cpMatchingPaths = findBundleClassPathMatchingPaths(bundle, path);
foundPaths.addAll(cpMatchingPaths);
}
}
}
示例6: matcherAnt
import org.springframework.util.PathMatcher; //導入方法依賴的package包/類
public static boolean matcherAnt(String reg,String str){
PathMatcher matcher = new AntPathMatcher();
return matcher.match(reg, str);
}
示例7: main
import org.springframework.util.PathMatcher; //導入方法依賴的package包/類
/**
* @param args
*/
public static void main(String[] args) {
PathMatcher pathMatcher = new AntPathMatcher();
boolean result = pathMatcher.match("admin/**/*.html", "admin/sdfsf.html");
System.out.println("result = " + result);
}
示例8: findImportedBundleMatchingResource
import org.springframework.util.PathMatcher; //導入方法依賴的package包/類
/**
* Searches for the given pattern inside the imported bundle. This
* translates to pattern matching on the imported packages.
*
* @param importedBundle imported bundle
* @param path path used for pattern matching
* @param foundPaths collection of found results
*/
private void findImportedBundleMatchingResource(final ImportedBundle importedBundle, String rootPath, String path,
final Collection foundPaths) throws IOException {
final boolean trace = logger.isTraceEnabled();
String[] packages = importedBundle.getImportedPackages();
if (trace)
logger.trace("Searching path [" + path + "] on imported pkgs " + ObjectUtils.nullSafeToString(packages)
+ "...");
final boolean startsWithSlash = rootPath.startsWith(FOLDER_SEPARATOR);
for (int i = 0; i < packages.length; i++) {
// transform the package name into a path
String pkg = packages[i].replace(DOT, SLASH) + SLASH;
if (startsWithSlash) {
pkg = FOLDER_SEPARATOR + pkg;
}
final PathMatcher matcher = getPathMatcher();
// if the imported package matches the path
if (matcher.matchStart(path, pkg)) {
Bundle bundle = importedBundle.getBundle();
// 1. look at the Bundle jar root
Enumeration entries = bundle.getEntryPaths(pkg);
while (entries != null && entries.hasMoreElements()) {
String entry = (String) entries.nextElement();
if (startsWithSlash)
entry = FOLDER_SEPARATOR + entry;
if (matcher.match(path, entry)) {
if (trace)
logger.trace("Found entry [" + entry + "]");
foundPaths.add(entry);
}
}
// 2. Do a Bundle-Classpath lookup (since the jar might use a different classpath)
Collection cpMatchingPaths = findBundleClassPathMatchingPaths(bundle, path);
foundPaths.addAll(cpMatchingPaths);
}
}
}
示例9: matcherAnt
import org.springframework.util.PathMatcher; //導入方法依賴的package包/類
/**
* ANT匹配字符串
* @param str 需要匹配的字符串
* @param reg ANT表達式
* @return 是否匹配到
*/
public static boolean matcherAnt(String reg,String str){
PathMatcher matcher = new AntPathMatcher();
return matcher.match(reg, str);
}