/** * Match the given <code>path</code> against the corresponding part of the given * <code>pattern</code>, according to this PathMatcher's matching strategy. * <p>Determines whether the pattern at least matches as far as the given base * path goes, assuming that a full path may then match as well. * * @param pattern the pattern to match against * @param path the path String to test * @return <code>true</code> if the supplied <code>path</code> matched, * <code>false</code> if it didn't */ public static boolean matchStart(String pattern, String path) { return doMatch(pattern, path, false); }
/** * get rootPath from locationPattern. * <p> * if "/context/** / *.xml" should get the result "/context/" * </p> * * @param locationPattern locationPattern * @return the RootPath string. */ private static String getRootPath(final String locationPattern) { int rootDirEnd = locationPattern.length(); while (AntPathMatcher.isPattern(locationPattern.substring(0, rootDirEnd))) { rootDirEnd = locationPattern.lastIndexOf('/', rootDirEnd - 2) + 1; } return locationPattern.substring(0, rootDirEnd); }
@Override public boolean accept(final File file) { if (file.isDirectory()) { return false; } if (AntPathMatcher.match(filePattern, StringUtils.replace(file.getAbsolutePath(), File.separator, "/"))) { return true; } return false; } }, TrueFileFilter.INSTANCE);
String[] pattDirs = tokenizeToStringArray(pattern, pathSeparator); String[] pathDirs = tokenizeToStringArray(path, pathSeparator); break; if (!matchStrings(patDir, pathDirs[pathIdxStart])) { return false; break; if (!matchStrings(patDir, pathDirs[pathIdxEnd])) { return false; String subStr = (String) pathDirs[pathIdxStart + i + j]; if (!matchStrings(subPat, subStr)) { continue strLoop;
return toStringArray(tokens);
String[] patternParts = tokenizeToStringArray(pattern, pathSeparator); String[] pathParts = tokenizeToStringArray(path, pathSeparator);
String[] pattDirs = tokenizeToStringArray(pattern, pathSeparator); String[] pathDirs = tokenizeToStringArray(path, pathSeparator); break; if (!matchStrings(patDir, pathDirs[pathIdxStart])) { return false; break; if (!matchStrings(patDir, pathDirs[pathIdxEnd])) { return false; String subStr = (String) pathDirs[pathIdxStart + i + j]; if (!matchStrings(subPat, subStr)) { continue strLoop;
return toStringArray(tokens);
String[] patternParts = tokenizeToStringArray(pattern, pathSeparator); String[] pathParts = tokenizeToStringArray(path, pathSeparator);
/** * Determines whether the client requests a static resource with the specified request. * * @param request the specified request * @return {@code true} if the client requests a static resource, returns {@code false} otherwise */ public static boolean isStatic(final HttpServletRequest request) { final boolean requestStaticResourceChecked = null == request.getAttribute(Keys.HttpRequest.REQUEST_STATIC_RESOURCE_CHECKED) ? false : (Boolean) request.getAttribute(Keys.HttpRequest.REQUEST_STATIC_RESOURCE_CHECKED); if (requestStaticResourceChecked) { return (Boolean) request.getAttribute(Keys.HttpRequest.IS_REQUEST_STATIC_RESOURCE); } if (!inited) { init(); } request.setAttribute(Keys.HttpRequest.REQUEST_STATIC_RESOURCE_CHECKED, true); request.setAttribute(Keys.HttpRequest.IS_REQUEST_STATIC_RESOURCE, false); final String requestURI = request.getRequestURI(); for (final String pattern : STATIC_RESOURCE_PATHS) { if (AntPathMatcher.match(Latkes.getContextPath() + pattern, requestURI)) { request.setAttribute(Keys.HttpRequest.IS_REQUEST_STATIC_RESOURCE, true); return true; } } return false; }
/** * Does the given <code>path</code> represent a pattern that can be matched * by an implementation of this interface? * <p>If the return value is <code>false</code>, then the {@link #match} * method does not have to be used because direct equality comparisons * on the static path Strings will lead to the same result. * * @param path the path String to check * @return <code>true</code> if the given <code>path</code> represents a pattern */ public static boolean match(String pattern, String path) { return doMatch(pattern, path, true); }
if (!AntPathMatcher.isPattern(path)) { path = path.replaceAll("\\.", "/") + "/**/*.class";
relativePath = entryPath.substring(rootEntryPath.length()); if (AntPathMatcher.match(subPattern, relativePath)) { if (relativePath.startsWith("/")) { relativePath = relativePath.substring(1);
/** * Does the given <code>path</code> represent a pattern that can be matched * by an implementation of this interface? * <p>If the return value is <code>false</code>, then the {@link #match} * method does not have to be used because direct equality comparisons * on the static path Strings will lead to the same result. * * @param path the path String to check * @return <code>true</code> if the given <code>path</code> represents a pattern */ public static boolean match(String pattern, String path) { return doMatch(pattern, path, true); }
/** * get rootPath from locationPattern. * <p> * if "/context/** / *.xml" should get the result "/context/" * </p> * * @param locationPattern locationPattern * @return the RootPath string. */ private static String getRootPath(final String locationPattern) { int rootDirEnd = locationPattern.length(); while (AntPathMatcher.isPattern(locationPattern.substring(0, rootDirEnd))) { rootDirEnd = locationPattern.lastIndexOf('/', rootDirEnd - 2) + 1; } return locationPattern.substring(0, rootDirEnd); }
@Override public boolean accept(final File file) { if (file.isDirectory()) { return false; } if (AntPathMatcher.match(filePattern, StringUtils.replace(file.getAbsolutePath(), File.separator, "/"))) { return true; } return false; } }, TrueFileFilter.INSTANCE);
/** * Match the given <code>path</code> against the corresponding part of the given * <code>pattern</code>, according to this PathMatcher's matching strategy. * <p>Determines whether the pattern at least matches as far as the given base * path goes, assuming that a full path may then match as well. * * @param pattern the pattern to match against * @param path the path String to test * @return <code>true</code> if the supplied <code>path</code> matched, * <code>false</code> if it didn't */ public static boolean matchStart(String pattern, String path) { return doMatch(pattern, path, false); }
if (!AntPathMatcher.isPattern(path)) { path = path.replaceAll("\\.", "/") + "/**/*.class";
/** * Determines whether the client requests a static resource with the specified request. * * @param request the specified request * @return {@code true} if the client requests a static resource, returns {@code false} otherwise */ public static boolean isStatic(final HttpServletRequest request) { final boolean requestStaticResourceChecked = null == request.getAttribute(Keys.HttpRequest.REQUEST_STATIC_RESOURCE_CHECKED) ? false : (Boolean) request.getAttribute(Keys.HttpRequest.REQUEST_STATIC_RESOURCE_CHECKED); if (requestStaticResourceChecked) { return (Boolean) request.getAttribute(Keys.HttpRequest.IS_REQUEST_STATIC_RESOURCE); } if (!inited) { init(); } request.setAttribute(Keys.HttpRequest.REQUEST_STATIC_RESOURCE_CHECKED, true); request.setAttribute(Keys.HttpRequest.IS_REQUEST_STATIC_RESOURCE, false); final String requestURI = request.getRequestURI(); for (final String pattern : STATIC_RESOURCE_PATHS) { if (AntPathMatcher.match(Latkes.getContextPath() + pattern, requestURI)) { request.setAttribute(Keys.HttpRequest.IS_REQUEST_STATIC_RESOURCE, true); return true; } } return false; }
relativePath = entryPath.substring(rootEntryPath.length()); if (AntPathMatcher.match(subPattern, relativePath)) { if (relativePath.startsWith("/")) { relativePath = relativePath.substring(1);