@Override public String extractRootDirPath(String location) { int prefixEnd = location.indexOf(":") + 1; int rootDirEnd = location.length(); while (rootDirEnd > prefixEnd && getPathMatcher().isPattern(location.substring(prefixEnd, rootDirEnd))) { rootDirEnd = location.lastIndexOf('/', rootDirEnd - 2) + 1; } if (rootDirEnd == 0) { rootDirEnd = prefixEnd; } return location.substring(0, rootDirEnd); }
protected boolean matchPatterns(String path){ for(int i=0;i<patterns.length;i++){ if(patternMatcher.match(patterns[i], path)){ return true; } } return false; }
if (content.isDirectory() && getPathMatcher().matchStart(fullPattern, currPath + "/")) { if (!content.canRead()) { if (logger.isTraceEnabled()) { if (getPathMatcher().match(fullPattern, currPath)) { result.add(content);
@Override public boolean matches(RequestBase request) { String path = request.getPath(ignoreCase); return isPattern ? matcher.match(pattern, path) : pattern.equals(path); } }
public PathPatternRequestMatcher(String path,PathMatcher matcher, boolean ignroeCase) { Args.notNull(path); Args.notNull(matcher); this.path = path; this.matcher = matcher; this.isPattern = matcher.isPattern(path); this.ignoreCase = ignroeCase; this.pattern = ignroeCase ? path.toLowerCase() : path; }
public void visit(Object vfsResource) { String relativePath = VfsUtils.getPath(vfsResource).substring(this.rootPath.length()); if (this.pathMatcher.match(this.subPattern,relativePath)) { this.resources.add(new VfsResource(vfsResource)); } }
protected void parsePatterns(String patterns){ if(!Strings.isEmpty(patterns)){ if(ignoreCase){ patterns = patterns.toLowerCase(); } Set<String> set = new LinkedHashSet<String>(); String[] lines = Strings.splitMultiLines(patterns); for(String line : lines){ if(!Strings.isEmpty(line = line.trim())){ if(!line.startsWith("/")){ line = "/" + line; } if(!patternMatcher.isPattern(line)){ throw new IllegalArgumentException("'" + line + "' is not a valid ant path pattern"); } set.add(line); } } if(!set.isEmpty()){ this.patterns = set.toArray(new String[set.size()]); } } }
@Override @SuppressWarnings("unchecked") public ServletResource[] scan(String subPattern) { Args.notEmpty(subPattern,"subPattern"); Set<String> subPaths = this.servletContext.getResourcePaths(this.path); List<SimpleServletResource> resources = new ArrayList<>(); PathMatcher matcher = Resources.getPathMatcher(); for(String subPath : subPaths){ if(matcher.match(subPattern, subPath)){ resources.add(new SimpleServletResource(servletContext, subPath)); } } return resources.toArray(new SimpleServletResource[resources.size()]); }
public Resource[] scan(String locationPattern) throws IOException { Args.notNull(locationPattern, "Location pattern"); if (locationPattern.startsWith(Urls.CLASSPATH_ALL_URL_PREFIX)) { String locationPatternWithPrefix = locationPattern.substring(Urls.CLASSPATH_ALL_URL_PREFIX.length()); // a class path resource (multiple resources for same name possible) if (getPathMatcher().isPattern(locationPatternWithPrefix)) { // a class path resource pattern return findPathMatchingResources(locationPattern); } else { // all class path resources with the given name return findAllClassPathResources(locationPatternWithPrefix); } } else { // Only look for a pattern after a prefix here // (to not get fooled by a pattern symbol in a strange prefix). int prefixEnd = locationPattern.indexOf(":") + 1; if (getPathMatcher().isPattern(locationPattern.substring(prefixEnd))) { // a file pattern return findPathMatchingResources(locationPattern); } else { // a single resource with the given name return new Resource[] {getResourceLoader().getResource(locationPattern)}; } } }
@Override public Resource[] searchClasspaths(String... classpathPatterns) { Args.notNull(classpathPatterns,"classpath patterns"); Set<Resource> resources = new LinkedHashSet<Resource>(); for(String classpathPattern : classpathPatterns){ if(classpathPattern.startsWith("/")){ classpathPattern = classpathPattern.substring(1); } for(int i=0;i<values.length;i++){ Resource resource = values[i]; if(null != resource.getClasspath()){ if(Resources.matcher.match(classpathPattern,resource.getClasspath())){ resources.add(resource); } } } } return resources.toArray(new Resource[resources.size()]); }
@Override public Resource[] searchUrls(String... locationPatterns) { Args.notNull(locationPatterns,"location patterns"); Set<Resource> resources = new LinkedHashSet<Resource>(); for(String locationPattern : locationPatterns){ try { for(int i=0;i<values.length;i++){ Resource resource = values[i]; if(Resources.matcher.match(locationPattern,resource.getURL().toExternalForm())){ resources.add(resource); } } } catch (IOException e) { throw new NestedIOException(e); } } return resources.toArray(new Resource[resources.size()]); }
public AppResource[] searchResources(String[] patterns){ Set<AppResource> set = new TreeSet<>(new ResourceComparator()); final PathMatcher matcher = Resources.getPathMatcher(); for(String namedPattern : patterns){ if(namedPattern.startsWith("/")){ namedPattern = namedPattern.substring(1); } for(AppResource r : sortedResources) { if(null != r.getPath()) { String path = r.getPath(); if(matcher.match(namedPattern, path)) { set.add(r); } } } } return set.toArray(new AppResource[0]); }
if (entryPath.startsWith(rootEntryPath)) { String relativePath = entryPath.substring(rootEntryPath.length()); if (getPathMatcher().match(subPattern, relativePath)) { result.add(rootDirResource.createRelative(relativePath));