@Test public void testMatches() throws Exception { Path baseFolder = new Path("tests/res/PathMatcherTest"); FList<String> wc = new FList<>("test1.txt", "./test3.*"); PathMatcher matcher = new PathMatcher(wc, baseFolder); assertTrue(matcher.matches(baseFolder.combination("test1.txt"))); assertFalse(matcher.matches(new Path("test3.bin"))); assertTrue(matcher.matches(baseFolder.combination("test3.bin"))); }
public boolean matches(String[] segments, int startIndex) { int remaining = segments.length - startIndex; if (remaining < minSegments || remaining > maxSegments) { return false; } int pos = startIndex; for (int i = 0; i < steps.size(); i++, pos++) { PatternStep step = steps.get(i); if (!step.matches(segments[pos])) { return false; } } return next.matches(segments, pos); }
// it compares the link if it is equal to .html then it will be added to the list. private void find(Path file) { Path name = file.getFileName(); if (name != null && matcher.matches(name)) { numMatches++; int i = -1; String shortPath = file.toString(); i = shortPath.indexOf("-lewis"); shortPath = shortPath.substring(i + 7, shortPath.length()); URI newLink = new File(file.toString()).toURI(); // System.out.println("Antes :" +newLink.toString() ); newLink = newLink.normalize(); linksMatches.add(newLink.toString().substring(6)); } }
@Override public boolean allowed( final MavenProxyRepository mavenProxyRepository, final ResourceStoreRequest resourceStoreRequest) { final PathMatcher pathMatcher = getPathMatcherFor(mavenProxyRepository); if (pathMatcher != null) { final boolean allowed = pathMatcher.matches(resourceStoreRequest.getRequestPath()); if (!allowed) { // flag the request as rejected resourceStoreRequest .getRequestContext() .put(Manager.ROUTING_REQUEST_REJECTED_FLAG_KEY, Boolean.TRUE); } return allowed; } else { // no pathMatcher for a proxy, it does not publishes it return true; } }
void find(Path file) { Path name = file.getFileName(); if (name != null && pathMatcher.matches(name)) { System.out.println(name); } }
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (_pathMatcher.matches(file.getFileName())) storeFile(file.toFile()); return super.visitFile(file, attrs); }