Examples of PathMatcher


Examples of com.bj58.argo.thirdparty.PathMatcher

*/
public class PathMatcherTest {

    @Test
    public void test() {
        PathMatcher pathMatcher = new AntPathMatcher();

        String pattern = "/{a}/{b}/{c}";

        String sample = "/aa/bb/cc";

        Assert.assertTrue(pathMatcher.match(pattern, sample));

    }
View Full Code Here

Examples of com.bj58.argo.thirdparty.PathMatcher

    }


    @Test
    public void testPathMatch(){
        PathMatcher pathMatcher = new AntPathMatcher();
        String registeredPath = "/me/hello/{name}";
        String url = "/me/hello/renjun";
        Assert.assertTrue(pathMatcher.match(registeredPath, url));

        Map<String, String> values = pathMatcher.extractUriTemplateVariables(registeredPath, url);
        Assert.assertEquals(1, values.size());
        Assert.assertEquals("renjun", values.get("name"));

        System.out.println("OK testpathMatch");
View Full Code Here

Examples of java.nio.file.PathMatcher

    }

    private static List<File> findFiles(File incPath, String searchArgument, boolean findDirectory) {
        ArrayList<File> files = new ArrayList<>();

        final PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:**");
         DirectoryStream.Filter<Path> filter = new DirectoryStream.Filter<Path>() {
            @Override
            public boolean accept(Path entry)  {
                return matcher.matches(entry.getFileName());
            }
        };

        if(starPattern.matcher(searchArgument).matches()) {
            try (DirectoryStream<Path> stream = findDirectory ?
View Full Code Here

Examples of java.nio.file.PathMatcher

            pattern = Joiner.on("/").join(patternParts.subList(i, patternParts.size()));
          }
        }
      }

      final PathMatcher matcher = fs.getPathMatcher("glob:" + pattern);
      java.nio.file.Files.walkFileTree(
          fs.getPath(prefix), new SimpleFileVisitor<Path>() {
            @Override public FileVisitResult visitFile(
                Path p, BasicFileAttributes attrs) {
              if (matcher.matches(p)) {
                if (remove) {
                  allJsInputs.remove(p.toString());
                } else {
                  allJsInputs.add(p.toString());
                }
View Full Code Here

Examples of java.nio.file.PathMatcher

        }

        List<Path> hits = new ArrayList<>();
        if (FS.isValidDirectory(dir))
        {
            PathMatcher matcher = PathMatchers.getMatcher(pattern);
            PathFinder finder = new PathFinder();
            finder.setFileMatcher(matcher);
            finder.setBase(dir);
            finder.setIncludeDirsInResults(true);
            Files.walkFileTree(dir,SEARCH_VISIT_OPTIONS,searchDepth,finder);
View Full Code Here

Examples of java.nio.file.PathMatcher

            // Perform absolute path pattern search

            // The root to start search from
            Path root = PathMatchers.getSearchRoot(pattern);
            // The matcher for file hits
            PathMatcher matcher = PathMatchers.getMatcher(pattern);

            if (FS.isValidDirectory(root))
            {
                PathFinder finder = new PathFinder();
                finder.setIncludeDirsInResults(true);
                finder.setFileMatcher(matcher);
                finder.setBase(root);
                Files.walkFileTree(root,SEARCH_VISIT_OPTIONS,MAX_SEARCH_DEPTH,finder);
                hits.addAll(finder.getHits());
            }
        }
        else
        {
            // Perform relative path pattern search
            Path relativePath = PathMatchers.getSearchRoot(pattern);
            PathMatcher matcher = PathMatchers.getMatcher(pattern);
            PathFinder finder = new PathFinder();
            finder.setIncludeDirsInResults(true);
            finder.setFileMatcher(matcher);

            // walk config sources backwards ...
View Full Code Here

Examples of java.nio.file.PathMatcher

    {
        System.out.println("Copying libs (lib dir) ...");
        Path libsDir = destDir.resolve("lib");
        FS.ensureDirExists(libsDir.toFile());

        PathMatcher matcher = getPathMatcher("glob:**.jar");
        Renamer renamer = new RegexRenamer("-9\\.[0-9.]*(v[0-9]*)?(-SNAPSHOT)?(RC[0-9])?(M[0-9])?","-TEST");
        FileCopier copier = new TouchFileCopier();
        copyDir(srcDir.resolve("lib"),libsDir,matcher,renamer,copier);
    }
View Full Code Here

Examples of java.nio.file.PathMatcher

    {
        System.out.println("Copying modules ...");
        Path modulesDir = destDir.resolve("modules");
        FS.ensureDirExists(modulesDir.toFile());

        PathMatcher matcher = getPathMatcher("glob:**.mod");
        Renamer renamer = new NoRenamer();
        FileCopier copier = new NormalFileCopier();
        copyDir(srcDir.resolve("modules"),modulesDir,matcher,renamer,copier);
    }
View Full Code Here

Examples of java.nio.file.PathMatcher

    {
        System.out.println("Copying xmls (etc dir) ...");
        Path xmlDir = destDir.resolve("etc");
        FS.ensureDirExists(xmlDir.toFile());

        PathMatcher matcher = getPathMatcher("glob:**.xml");
        Renamer renamer = new NoRenamer();
        FileCopier copier = new TouchFileCopier();
        copyDir(srcDir.resolve("etc"),xmlDir,matcher,renamer,copier);
    }
View Full Code Here

Examples of java.nio.file.PathMatcher

    }

    private static List<File> findFiles(File incPath, String searchArgument, boolean findDirectory) {
        ArrayList<File> files = new ArrayList<>();

        final PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:**");
         DirectoryStream.Filter<Path> filter = new DirectoryStream.Filter<Path>() {
            @Override
            public boolean accept(Path entry)  {
                return matcher.matches(entry.getFileName());
            }
        };

        if(starPattern.matcher(searchArgument).matches()) {
            try (DirectoryStream<Path> stream = findDirectory ?
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.