/** * 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 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 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); }
/** * 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); }
/** * 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); }
/** * The heart of the matter. This is where the selector gets to decide * on the inclusion of a file in a particular fileset. Most of the work * for this selector is offloaded into SelectorUtils, a static class * that provides the same services for both FilenameSelector and * DirectoryScanner. * * @param basedir the base directory the scan is being done from * @param filename is the name of the file to check * @param file is a java.io.File object the selector can use * @return whether the file should be selected or not */ public boolean isSelected(File basedir, String filename, File file) { validate(); if (pattern != null) { return SelectorUtils.matchPath(pattern, filename, casesensitive) == !(negated); } if (reg == null) { reg = new RegularExpression(); reg.setPattern(regex); expression = reg.getRegexp(getProject()); } int options = RegexpUtil.asOptions(casesensitive); return expression.matches(filename, options) == !negated; }
public boolean matchesDefaultExclusions( String relativePath ) { // Correct the slash pattern. relativePath = relativePath.replace( '\\', '/' ); for ( String pattern : DEFAULT_EXCLUSIONS ) { if ( SelectorUtils.matchPath( pattern, relativePath, false ) ) { // Found match return true; } } // No match. return false; }
public boolean matchesDefaultExclusions( String relativePath ) { // Correct the slash pattern. relativePath = relativePath.replace( '\\', '/' ); for ( String pattern : DEFAULT_EXCLUSIONS ) { if ( SelectorUtils.matchPath( pattern, relativePath, false ) ) { // Found match return true; } } // No match. return false; }
@Override public boolean matches(String pattern, String str) { // Replace the Git directory separator character (always '/') // with the platform specific directory separator before // invoking Ant's platform specific path matching. String safePattern = pattern.replace('/', File.separatorChar); String safeStr = str.replace('/', File.separatorChar); return SelectorUtils.matchPath(safePattern, safeStr); }
boolean matches(String path, String glob) { String safeGlob = glob.replace('/', File.separatorChar); String safePath = path.replace('/', File.separatorChar); return SelectorUtils.matchPath(safeGlob, safePath); } }
boolean matches(String path, String glob) { String safeGlob = glob.replace('/', File.separatorChar); String safePath = path.replace('/', File.separatorChar); return SelectorUtils.matchPath(safeGlob, safePath); } }
public boolean branchMatches(String toCompare, String actualBranch) { if (isEmpty(actualBranch) && isEmpty(toCompare)) { return true; } else if (isEmpty(actualBranch) || isEmpty(toCompare)) { return false; } // Replace the Git directory separator character (always '/') // with the platform specific directory separator before // invoking Ant's platform specific path matching. String safeCompare = toCompare.replace('/', File.separatorChar); String safeName = actualBranch.replace('/', File.separatorChar); return SelectorUtils.matchPath(safeCompare, safeName, false); }
@Override public boolean compare(@Nonnull String pattern, String actual) { actual = defaultIfBlank(actual, ""); // replace with the platform specific directory separator before // invoking Ant's platform specific path matching. String safeCompare = pattern.replace('/', File.separatorChar); String safeName = actual.replace('/', File.separatorChar); return SelectorUtils.matchPath(safeCompare, safeName, false); } },
public synchronized boolean matchesArtifactPattern( String relativePath ) { // Correct the slash pattern. relativePath = relativePath.replace( '\\', '/' ); if ( artifactPatterns == null ) { artifactPatterns = getFileTypePatterns( ARTIFACTS ); } for ( String pattern : artifactPatterns ) { if ( SelectorUtils.matchPath( pattern, relativePath, false ) ) { // Found match return true; } } // No match. return false; }
public synchronized boolean matchesArtifactPattern( String relativePath ) { // Correct the slash pattern. relativePath = relativePath.replace( '\\', '/' ); if ( artifactPatterns == null ) { artifactPatterns = getFileTypePatterns( ARTIFACTS ); } for ( String pattern : artifactPatterns ) { if ( SelectorUtils.matchPath( pattern, relativePath, false ) ) { // Found match return true; } } // No match. return false; }
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; } }
/** * Check whether a path (/-separated) will be archived. */ public boolean artifactMatches(String path, AbstractBuild<?, ?> build) { ArtifactArchiver aa = build.getProject().getPublishersList().get(ArtifactArchiver.class); if (aa == null) { //LOGGER.finer("No ArtifactArchiver found"); return false; } String artifacts = aa.getArtifacts(); for (String include : artifacts.split("[, ]+")) { String pattern = include.replace(File.separatorChar, '/'); if (pattern.endsWith("/")) { pattern += "**"; } if (SelectorUtils.matchPath(pattern, path)) { //LOGGER.log(Level.FINER, "DescriptorImpl.artifactMatches true for {0} against {1}", // new Object[]{path, pattern}); return true; } } //LOGGER.log(Level.FINER, "DescriptorImpl.artifactMatches for {0} matched none of {1}", // new Object[]{path, artifacts}); return false; }
/** * Check whether a path (/-separated) will be archived. */ public boolean artifactMatches(String path, AbstractBuild<?, ?> build) { ArtifactArchiver aa = build.getProject().getPublishersList().get(ArtifactArchiver.class); if (aa == null) { //LOGGER.finer("No ArtifactArchiver found"); return false; } String artifacts = aa.getArtifacts(); for (String include : artifacts.split("[, ]+")) { String pattern = include.replace(File.separatorChar, '/'); if (pattern.endsWith("/")) { pattern += "**"; } if (SelectorUtils.matchPath(pattern, path)) { //LOGGER.log(Level.FINER, "DescriptorImpl.artifactMatches true for {0} against {1}", // new Object[]{path, pattern}); return true; } } //LOGGER.log(Level.FINER, "DescriptorImpl.artifactMatches for {0} matched none of {1}", // new Object[]{path, artifacts}); return false; } }
/** * Check whether a path (/-separated) will be archived. */ public boolean artifactMatches(String path, AbstractBuild<?, ?> build) { ArtifactArchiver aa = build.getProject().getPublishersList().get(ArtifactArchiver.class); if (aa == null) { //LOGGER.finer("No ArtifactArchiver found"); return false; } String artifacts = aa.getArtifacts(); for (String include : artifacts.split("[, ]+")) { String pattern = include.replace(File.separatorChar, '/'); if (pattern.endsWith("/")) { pattern += "**"; } if (SelectorUtils.matchPath(pattern, path)) { //LOGGER.log(Level.FINER, "DescriptorImpl.artifactMatches true for {0} against {1}", // new Object[]{path, pattern}); return true; } } //LOGGER.log(Level.FINER, "DescriptorImpl.artifactMatches for {0} matched none of {1}", // new Object[]{path, artifacts}); return false; }