Java 8 PathMatcher - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 PathMatcher class.

This code example shows how to use the following methods:matches
    } 
 
    @Override 
    public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException
    { 
        if (dirMatcher.matches(dir))
        { 
            StartLog.trace("Following dir: " + dir);
            if (includeDirsInResults && fileMatcher.matches(dir))
            { 
                addHit(dir);
            } 
            return FileVisitResult.CONTINUE;
        } 
        else 
        { 
            StartLog.trace("Skipping dir: " + dir);
            return FileVisitResult.SKIP_SUBTREE;
        } 
    } 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:matches
        } 
 
        @Override 
        public FileVisitResult visitFile(Path path, BasicFileAttributes attrs) throws IOException {
            Path rel = root.relativize(path);
            if (pathMatcher.matches(rel)) {
                Path dstPath = basedir.resolve(rel);
                try { 
                    copy(path, dstPath);
                } catch (Exception e) {
                    throw new RuntimeException("Error while copying " + path + " to " + dstPath, e);
                } 
            } 
            return FileVisitResult.CONTINUE;
        } 
 
        private void copy(Path path, Path dstPath) throws IOException {
            File dstParent = dstPath.toFile().getParentFile();
            if (!dstParent.exists()) {
                if (!dstParent.mkdirs()) {
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:matches
	public boolean fileMatches(Path file)
	{ 
		Path name = file.getFileName();
		if (name == null)
			return false; 
		return matcher.matches(name);
	} 
	 
} 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:matches
 
    protected boolean isMatchesFile(Path file) {
        boolean matches = true;
        if (fileMatcher != null) {
            Path rel = root.relativize(file);
            matches = fileMatcher.matches(rel);
        } 
        return matches;
    } 
 
    private void unscan(final Path file) throws IOException {
        if (isMatchesFile(file)) {
            onRemove(file);
            lastModified = System.currentTimeMillis();
        } else { 
            // lets find all the files that now no longer exist 
            List<Path> files = new ArrayList<Path>(processedMap.keySet());
            for (Path path : files) {
                if (!Files.exists(path)) {
                    debug("File has been deleted: " + path);
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:matches
    public static DirectoryStream.Filter<Path> buildGlobFilter(String pattern) {
        final PathMatcher pathMatcher = getPathMatcher("glob:"+pattern);
        return new DirectoryStream.Filter<Path>() {
            @Override 
            public boolean accept(Path entry) throws IOException {
                return pathMatcher.matches(entry);
            } 
        }; 
    } 
 
    public static DirectoryStream.Filter<Path> buildRegexFilter(String pattern) {
        final PathMatcher pathMatcher = getPathMatcher("regex:"+pattern);
        return new DirectoryStream.Filter<Path>() {
            @Override 
            public boolean accept(Path entry) throws IOException {
                return pathMatcher.matches(entry);
            } 
        }; 
    } 
     
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:matches
        public NotMatcher(PathMatcher matcher) {
            this.matcher = matcher;
        } 
        @Override 
        public boolean matches(Path path) {
            return !matcher.matches(path);
        } 
    } 
 
} 
3
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:matches
  @Test
  public void matches() { 
    FileSystem fileSystem = this.rule.getFileSystem();
    Path path = fileSystem.getPath(this.p);
    PathMatcher matcher = fileSystem.getPathMatcher(GlobPathMatcher.name() + ":" + this.pattern);
    assertEquals(this.expected, matcher.matches(path));
  } 
 
  @Parameters(name = "pattern: {0}, path: {1}, should match: {2}") 
  public static List<Object[]> data() {
    return Arrays.asList(new Object[][] {
            { "*.java", "GlobPathMatcherTest.java", true }, 
            { "*.java", "GlobPathMatcherTest.JAVA", true }, 
            { "*.JAVA", "GlobPathMatcherTest.java", true }, 
            { "*.j[a-z]va", "GlobPathMatcherTest.java", true }, 
            { "*.j[A-Z]va", "GlobPathMatcherTest.java", true }, 
            { "*.java", ".java", true }, 
            { "*.java", ".jav.java", true }, 
            { "*.java", ".jav.java", true }, 
            { "*.java", ".jav", false }, 
3
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:matches
  @Test
  public void matches() { 
    FileSystem fileSystem = this.rule.getFileSystem();
    Path path = fileSystem.getPath(this.p);
    PathMatcher matcher = fileSystem.getPathMatcher(RegexPathMatcher.name() + ":" + this.pattern);
    assertEquals(this.expected, matcher.matches(path));
  } 
 
  @Parameters 
  public static List<Object[]> data() {
    return Arrays.asList(new Object[][] {
            { ".*\\.java", "GlobPathMatcherTest.java", true }, 
            { ".*\\.java", ".java", true }, 
            { ".*\\.java", ".jav.java", true }, 
            { ".*\\.java", ".jav.java", true }, 
            { ".*\\.java", ".jav", false }, 
            { ".*\\.java", "java", false }, 
 
            { ".*\\..*", "GlobPathMatcherTest.java", true }, 
            { ".*\\..*", ".java", true }, 
3
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:matches
    @Nullable 
    public String filter(String sv) {
        if (sv == null) {
            return null; 
        } 
        if (compiled.matches(Paths.get(sv))) {
            return sv;
        } else { 
            return null; 
        } 
    } 
} 
3
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:matches
 
        private boolean hasMatch(Path path, List<PathMatcher> matchers)
        { 
            for (PathMatcher matcher : matchers)
            { 
                if (matcher.matches(path))
                { 
                    return true; 
                } 
            } 
            return false; 
        } 
 
        public boolean isExcluded(Path dir) throws IOException
        { 
            if (excludeHidden)
            { 
                if (Files.isHidden(dir))
                { 
                    if (NOISY_LOG.isDebugEnabled())
3
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Java 8 PathMatcher Methods: