Example usage for org.apache.commons.io FilenameUtils wildcardMatch

List of usage examples for org.apache.commons.io FilenameUtils wildcardMatch

Introduction

In this page you can find the example usage for org.apache.commons.io FilenameUtils wildcardMatch.

Prototype

public static boolean wildcardMatch(String filename, String wildcardMatcher, IOCase caseSensitivity) 

Source Link

Document

Checks a filename to see if it matches the specified wildcard matcher allowing control over case-sensitivity.

Usage

From source file:org.apache.torque.generator.file.WildcardFilter.java

/**
 * Returns whether a file matches the criteria of this filter.
 * If the file is a directory and <code>acceptDir</code> is false,
 * the file is rejected.//from  ww  w .ja v  a 2s  . c  o m
 * If the file is regular file and <code>acceptFile</code> is false,
 * the file is rejected.
 * If the filename does not match the wildcard filter, the file is
 * rejected.
 * If none of the above applies, the file is accepted.
 *
 * @return false if the file is rejected, true if it is accepted.
 */
public boolean accept(File file) {
    if (!acceptDir && file.isDirectory()) {
        return false;
    }
    if (!acceptFile && file.isFile()) {
        return false;
    }
    if (FilenameUtils.wildcardMatch(file.getName(), expression, IOCase.SENSITIVE)) {
        return true;
    }
    return false;
}

From source file:org.exoplatform.contact.service.impl.ContactServiceImpl.java

private List<String> excludeWildCardMatchs(List<String> sourceList, List<String> wildCards) throws Exception {
    List<String> groupIds = new ArrayList<String>();
    if (sourceList != null && !sourceList.isEmpty()) {
        for (String object : sourceList) {
            groupIds.add(object);/* w w w .  ja v a2 s  . c  o  m*/
        }
    }
    if (wildCards == null || wildCards.isEmpty() || sourceList == null || sourceList.isEmpty()) {
        return groupIds;
    }
    for (String wildCard : wildCards) {
        for (String s : sourceList) {
            if (FilenameUtils.wildcardMatch(s, wildCard, IOCase.INSENSITIVE)) {
                groupIds.remove(s);
            }
        }
    }
    return groupIds;
}

From source file:org.jahia.ajax.gwt.helper.NavigationHelper.java

protected static boolean matchesFilters(String nodeName, List<String> filters) {
    if (CollectionUtils.isEmpty(filters)) {
        return true;
    }//from   ww w  .  jav a 2  s.c o  m
    boolean matches = false;
    for (String wildcard : filters) {
        if (FilenameUtils.wildcardMatch(nodeName, wildcard, IOCase.INSENSITIVE)) {
            matches = true;
            break;
        }
    }
    return matches;
}

From source file:org.mule.el.function.WildcardExpressionLanguageFuntion.java

protected boolean isMatch(String wildcardPattern, String text, boolean caseSensitive) {
    return FilenameUtils.wildcardMatch(text, wildcardPattern,
            caseSensitive ? IOCase.SENSITIVE : IOCase.INSENSITIVE);
}

From source file:org.nuxeo.connect.packages.dependencies.TargetPlatformFilterHelper.java

/**
 * @param targetPlatforms The target platforms on which to check compliance.
 * @param targetPlatform The target platform to match with.
 * @since 1.4.24//w  ww . jav a2  s  . c o  m
 */
public static boolean isCompatibleWithTargetPlatform(String[] targetPlatforms, String targetPlatform) {
    if (targetPlatform == null || targetPlatforms == null || targetPlatforms.length == 0) {
        return true;
    }
    for (String target : targetPlatforms) {
        if (FilenameUtils.wildcardMatch(targetPlatform, target, IOCase.INSENSITIVE)) {
            return true;
        }
    }
    return false;
}

From source file:org.pentaho.platform.repository.RepositoryFilenameUtils.java

/**
 * Checks a filename to see if it matches the specified wildcard matcher, always testing case-sensitive.
 * <p/>//w  w  w  . j a  va  2 s  .c om
 * The wildcard matcher uses the characters '?' and '*' to represent a single or multiple wildcard characters.
 * This is the same as often found on Dos/Unix command lines. The check is case-sensitive always.
 * 
 * <pre>
 * wildcardMatch("c.txt", "*.txt")      --> true
 * wildcardMatch("c.txt", "*.jpg")      --> false
 * wildcardMatch("a/b/c.txt", "a/b/*")  --> true
 * wildcardMatch("c.txt", "*.???")      --> true
 * wildcardMatch("c.txt", "*.????")     --> false
 * </pre>
 * 
 * @param filename
 *          the filename to match on
 * @param wildcardMatcher
 *          the wildcard string to match against
 * @return true if the filename matches the wildcard string
 * @see IOCase#SENSITIVE
 */
public static boolean wildcardMatch(final String filename, final String wildcardMatcher) {
    return FilenameUtils.wildcardMatch(filename, wildcardMatcher, IOCase.SENSITIVE);
}

From source file:svnserver.repository.git.prop.GitIgnore.java

@Nullable
@Override/*from  w w w  . j  a  va  2  s. co m*/
public GitProperty createForChild(@NotNull String name, @NotNull FileMode fileMode) {
    if (rules.isEmpty() || (fileMode.getObjectType() == Constants.OBJ_BLOB)) {
        return null;
    }
    final List<String> localList = new ArrayList<>();
    final List<String> globalList = new ArrayList<>();
    final List<Rule> childRules = new ArrayList<>();
    for (Rule rule : rules) {
        if (rule.mask.equals("**")) {
            childRules.add(rule);
            final int index = rule.rule.indexOf('/', 1);
            if (rule.rule.substring(1, index).equals(name)) {
                processLine(localList, globalList, childRules, rule.rule.substring(index));
            }
        }
        if (FilenameUtils.wildcardMatch(name, rule.mask, IOCase.SENSITIVE)) {
            processLine(localList, globalList, childRules, rule.rule);
        }
    }
    if (localList.isEmpty() && globalList.isEmpty() && childRules.isEmpty()) {
        return null;
    }
    return new GitIgnore(localList, globalList, childRules);
}

From source file:us.terebi.lang.lpc.runtime.jvm.efun.file.GetDirectoryInfoEfun.java

protected static Resource[] resolveWildCard(ResourceFinder resourceFinder, String path) throws IOException {
    if (path.indexOf('*') == -1 && path.indexOf('?') == -1) {
        return new Resource[] { resourceFinder.getResource(path) };
    }// www . j  a va 2 s .c o  m

    List<Resource> match = new ArrayList<Resource>();

    int slash = path.lastIndexOf('/', path.length() - 1);
    String parentPath = path.substring(0, slash);
    String childPath = path.substring(slash + 1);

    Resource[] parents = resolveWildCard(resourceFinder, parentPath);
    for (Resource parent : parents) {
        Resource[] children = parent.getChildren();
        for (Resource child : children) {
            if (FilenameUtils.wildcardMatch(child.getName(), childPath, IOCase.INSENSITIVE)) {
                match.add(child);
            }
        }
    }

    return match.toArray(new Resource[match.size()]);
}