/** * Test whether or not a given path matches a given pattern. * * @param pattern The pattern to match against. Must not be * <code>null</code>. * @param str The path to match, as a String. Must not be * <code>null</code>. * * @return <code>true</code> if the pattern matches against the string, * or <code>false</code> otherwise. */ protected static boolean matchPath(final String pattern, final String str) { return SelectorUtils.matchPath(pattern, str); }
/** * Test whether or not a string matches against a pattern. * The pattern may contain two special characters:<br> * '*' means zero or more characters<br> * '?' means one and only one character * * @param pattern The pattern to match against. * Must not be <code>null</code>. * @param str The string which must be matched against the pattern. * Must not be <code>null</code>. * * @return <code>true</code> if the string matches against the pattern, * or <code>false</code> otherwise. */ public static boolean match(final String pattern, final String str) { return SelectorUtils.match(pattern, str); }
/** * Breaks a path up into a Vector of path elements, tokenizing on * <code>File.separator</code>. * * @param path Path to tokenize. Must not be <code>null</code>. * * @return a Vector of path elements from the tokenized path */ public static Vector<String> tokenizePath(String path) { return tokenizePath(path, File.separator); }
/** * Tests whether or not a given path matches a given pattern. * * If you need to call this method multiple times with the same * pattern you should rather use TokenizedPath * * @see TokenizedPath * * @param pattern The pattern to match against. Must not be * <code>null</code>. * @param str The path to match, as a String. Must not be * <code>null</code>. * * @return <code>true</code> if the pattern matches against the string, * or <code>false</code> otherwise. */ public static boolean matchPath(String pattern, String str) { String[] patDirs = tokenizePathAsArray(pattern); return matchPath(patDirs, tokenizePathAsArray(str), true); }
protected boolean accept(File pathname, final String path) { logger.debug("checking path: {}", path); for (final String include : this.includes) { if ((acceptDirectories && pathname.isDirectory()) || SelectorUtils.matchPath(include, path, false) || SelectorUtils.match(include, path, false)) { logger.debug("{} matches include {}", path, include); for (final String exclude : this.excludes) { if (SelectorUtils.matchPath(exclude, path, false)) { logger.debug("{} matches exclude {}", path, exclude); logger.debug("denied path: {}", path); return false; } else if (logger.isTraceEnabled()) { logger.trace("{} doesn't match exclude {}", path, exclude); } } logger.debug("acepted path: {}", path); return true; } else if (logger.isTraceEnabled()) { logger.trace("{} doesn't match include {}", path, include); } } logger.debug("denied path: {}", path); return false; } }
/** * Returns a new TokenizedPath where all tokens of this pattern to * the right containing wildcards have been removed * * @return the leftmost part of the pattern without wildcards */ public TokenizedPath rtrimWildcardTokens() { StringBuilder sb = new StringBuilder(); int newLen = 0; for (; newLen < tokenizedPattern.length; newLen++) { if (SelectorUtils.hasWildcards(tokenizedPattern[newLen])) { break; } if (newLen > 0 && sb.charAt(sb.length() - 1) != File.separatorChar) { sb.append(File.separator); } sb.append(tokenizedPattern[newLen]); } if (newLen == 0) { return TokenizedPath.EMPTY_PATH; } String[] newPats = new String[newLen]; System.arraycopy(tokenizedPattern, 0, newPats, 0, newLen); return new TokenizedPath(sb.toString(), newPats); }
/** * this test is our selection test that compared the file with the destfile * @param srcfile the source file * @param destfile the destination file * @return true if destination is out of date */ public boolean selectionTest(File srcfile, File destfile) { return SelectorUtils.isOutOfDate(srcfile, destfile, granularity); }
= SelectorUtils.rtrimWildcardTokens(include); newroots.put(newpattern, include);
protected boolean accept(File pathname, final String path) { logger.debug("checking path: {}", path); for (final String include : this.includes) { if ((acceptDirectories && pathname.isDirectory()) || SelectorUtils.matchPath(include, path, false) || SelectorUtils.match(include, path, false)) { logger.debug("{} matches include {}", path, include); for (final String exclude : this.excludes) { if (SelectorUtils.matchPath(exclude, path, false)) { logger.debug("{} matches exclude {}", path, exclude); logger.debug("denied path: {}", path); return false; } else if (logger.isTraceEnabled()) { logger.trace("{} doesn't match exclude {}", path, exclude); } } logger.debug("acepted path: {}", path); return true; } else if (logger.isTraceEnabled()) { logger.trace("{} doesn't match include {}", path, include); } } logger.debug("denied path: {}", path); return false; } }
/** * Tests whether or not a given path matches a given pattern. * * If you need to call this method multiple times with the same * pattern you should rather use TokenizedPattern * * @see TokenizedPattern * * @param pattern The pattern to match against. Must not be * <code>null</code>. * @param str The path to match, as a String. Must not be * <code>null</code>. * @param isCaseSensitive Whether or not matching should be performed * case sensitively. * * @return <code>true</code> if the pattern matches against the string, * or <code>false</code> otherwise. */ public static boolean matchPath(String pattern, String str, boolean isCaseSensitive) { String[] patDirs = tokenizePathAsArray(pattern); return matchPath(patDirs, tokenizePathAsArray(str), isCaseSensitive); }
/** * Add all patterns that are not real patterns (do not contain * wildcards) to the set and returns the real patterns. * * @param map Map to populate. * @param patterns String[] of patterns. * @since Ant 1.8.0 */ private TokenizedPattern[] fillNonPatternSet(final Map<String, TokenizedPath> map, final String[] patterns) { final List<TokenizedPattern> al = new ArrayList<>(patterns.length); for (String pattern : patterns) { if (SelectorUtils.hasWildcards(pattern)) { al.add(new TokenizedPattern(pattern)); } else { final String s = isCaseSensitive() ? pattern : pattern.toUpperCase(); map.put(s, new TokenizedPath(s)); } } return al.toArray(new TokenizedPattern[al.size()]); }
/** * Returns dependency information on these two resources. If src has been * modified later than target, it returns true. If target doesn't exist, * it likewise returns true. Otherwise, target is newer than src and * is not out of date, thus the method returns false. It also returns * false if the src file doesn't even exist, since how could the * target then be out of date. * * @param src the original resource * @param target the resource being compared against * @param granularity the int amount in seconds of slack we will give in * determining out of dateness * @return whether the target is out of date */ public static boolean isOutOfDate(Resource src, Resource target, int granularity) { return isOutOfDate(src, target, (long) granularity); }
SelectorUtils.rtrimWildcardTokens(include); newroots.put(newpattern, include);
/** * Test whether or not a given path matches a given pattern. * * @param pattern The pattern to match against. Must not be * <code>null</code>. * @param str The path to match, as a String. Must not be * <code>null</code>. * @param isCaseSensitive Whether or not matching should be performed * case sensitively. * * @return <code>true</code> if the pattern matches against the string, * or <code>false</code> otherwise. */ protected static boolean matchPath(final String pattern, final String str, final boolean isCaseSensitive) { return SelectorUtils.matchPath(pattern, str, isCaseSensitive); }
/** * Tests whether or not a string matches against a pattern. * The pattern may contain two special characters:<br> * '*' means zero or more characters<br> * '?' means one and only one character * * @param pattern The pattern to match against. * Must not be <code>null</code>. * @param str The string which must be matched against the pattern. * Must not be <code>null</code>. * * @return <code>true</code> if the string matches against the pattern, * or <code>false</code> otherwise. */ public static boolean match(String pattern, String str) { return match(pattern, str, true); }
List<String> pathElements = SelectorUtils.tokenizePath(getAbsolutePath(), remoteFileSep); StringBuilder relPath = new StringBuilder(currentRelativePath == null ? "" : currentRelativePath); for (String currentElement : pathElements.subList(SelectorUtils.tokenizePath(currentPath, remoteFileSep).size(), pathElements.size())) { FTPFile[] theFiles = listFiles(currentPath);
private String fixAntPattern(String pattern) { pattern = FilenameUtils.separatorsToSystem(pattern); if (!SelectorUtils.hasWildcards(pattern)) { pattern = "**" + File.separatorChar + pattern; } return pattern; }
private boolean isUpToDate(ResourceCollection c) { return dest != null && !forceOverwrite && c.stream().noneMatch(r -> SelectorUtils.isOutOfDate(r, dest, FILE_UTILS.getFileTimestampGranularity())); }
SelectorUtils.rtrimWildcardTokens(includes[icounter]); newroots.put(newpattern, includes[icounter]);
/** * Tests whether or not a given path matches a given pattern. * * @param path The path to match, as a String. Must not be * <code>null</code>. * @param isCaseSensitive Whether or not matching should be performed * case sensitively. * * @return <code>true</code> if the pattern matches against the string, * or <code>false</code> otherwise. */ public boolean matchPath(TokenizedPath path, boolean isCaseSensitive) { return SelectorUtils.matchPath(tokenizedPattern, path.getTokens(), isCaseSensitive); }