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) 

Source Link

Document

Checks a filename to see if it matches the specified wildcard matcher, always testing case-sensitive.

Usage

From source file:com.igormaznitsa.jute.Utils.java

public static boolean checkClassAndMethodForPattern(final String juteTest, final String className,
        final String methofName, final boolean onlyClass) {
    if (className == null || (!onlyClass && methofName == null)) {
        return false;
    }//from  w  ww .  j  a v  a2 s .  c om
    if (juteTest == null || juteTest.isEmpty()) {
        return true;
    }
    final String classPattern;
    final String methodPattern;
    final int methodPrefix = juteTest.indexOf('#');
    if (methodPrefix < 0) {
        classPattern = juteTest;
        methodPattern = "*";
    } else {
        classPattern = juteTest.substring(0, methodPrefix);
        methodPattern = juteTest.substring(methodPrefix + 1);
    }
    return FilenameUtils.wildcardMatch(className, classPattern)
            && (onlyClass ? true : FilenameUtils.wildcardMatch(methofName, methodPattern));
}

From source file:de.micromata.genome.util.matcher.string.WildcardMatcher.java

@Override
public boolean matchString(String token) {
    return FilenameUtils.wildcardMatch(token, pattern) == true;
}

From source file:de.micromata.genome.tpsb.httpmockup.MockWebElementConfig.java

public int getNextMapDef(String path, int offset) {
    if (path.startsWith("/") == false) {
        path = "/" + path;
    }//  w  w w  . j a  va2  s  .  c o  m
    List<? extends MockMapDef> mapDefs = getMappingDefs();
    for (int i = offset; i < mapDefs.size(); ++i) {
        MockMapDef md = mapDefs.get(i);
        String p = md.getUrlPattern();
        if (p == null) {
            return -1;
        }
        if (p.equals("/") == true) {
            return i;
        }
        if (md.getUrlMatcher().match(path) == true) {
            return i;
        }
        if (FilenameUtils.wildcardMatch(path, p) == true) {
            return i;
        }
    }
    return -1;
}

From source file:net.sf.jvifm.model.filter.WildcardFilter2.java

public boolean accept(File dir, String name) {
    for (int i = 0; i < wildcards.length; i++) {
        if (FilenameUtils.wildcardMatch(name, wildcards[i])) {
            return true;
        }/*from   w w  w. jav a2  s  . c om*/
    }
    return false;
}

From source file:net.sf.jvifm.model.filter.WildcardFilter2.java

public boolean accept(File file) {
    for (int i = 0; i < wildcards.length; i++) {
        if (FilenameUtils.wildcardMatch(file.getName(), wildcards[i])) {
            return true;
        }//from  www.  j  a  v a2  s . co m
    }
    return false;
}

From source file:com.thruzero.common.core.fs.WildcardFilter.java

/** if useWildcard is true, then return the result of the wildcard search; otherwise, return false. */
protected boolean test(final File file, final boolean useWildcard) {
    boolean result = false;

    if (useWildcard) {
        result = FilenameUtils.wildcardMatch(file.getName(), wildcard);
        result = invert ? !result : result;
    }/*from www  .j  a  v a2s. c  o  m*/

    return result;
}

From source file:com.igormaznitsa.jute.TestClassProcessor.java

private boolean isTestIncluded(final String testName) {
    if (testName.startsWith("<")) {
        return false;
    }//ww  w. j a v a  2 s.  c  om
    boolean result = true;
    if (this.includedTests != null && this.includedTests.length != 0) {
        result = false;
        for (final String wildcard : this.includedTests) {
            if (FilenameUtils.wildcardMatch(testName, wildcard)) {
                result = true;
                break;
            }
        }
    }
    return result;
}

From source file:com.igormaznitsa.jute.TestClassProcessor.java

private boolean isTestExcluded(final String testName) {
    if (testName.startsWith("<")) {
        return true;
    }//w  w w . j  a  v  a2 s .c om
    boolean result = false;
    if (this.excludedTests != null && this.excludedTests.length != 0) {
        result = false;
        for (final String wildcard : this.excludedTests) {
            if (FilenameUtils.wildcardMatch(testName, wildcard)) {
                result = true;
                break;
            }
        }
    }
    return result;
}

From source file:com.erdfelt.joakim.jsvntk.tasks.SetEolProp.java

private boolean matches(String name, String[] patterns) {
    for (String pattern : patterns) {
        if (FilenameUtils.wildcardMatch(name, pattern)) {
            return true;
        }//w w w.jav  a 2s. c om
    }
    return false;
}

From source file:com.pieframework.runtime.utils.ArtifactManager.java

private void copy(String download, String filter, String localPath, String virtualPath) {

    /*System.out.println("download:"+download+
             "\nfilter:"+filter+/*from   w  w  w.jav a  2 s . c  om*/
             "\nlocalPath:"+localPath+
             "\nvirtualPath:"+virtualPath);
    */
    boolean match = true;
    if (!StringUtils.empty(filter)) {
        match = FilenameUtils.wildcardMatch(FilenameUtils.separatorsToSystem(download), filter);
    }

    if (match) {

        File destinationVirtualFile = new File(FilenameUtils.separatorsToSystem(virtualPath));
        File destination = new File(localPath + destinationVirtualFile.getParent());
        destination.mkdirs();

        if (destination.exists()) {
            File downloadFile = new File(download);
            try {
                FileUtils.copyFileToDirectory(downloadFile, destination);
                File copiedFile = new File(
                        destination.getPath() + File.separatorChar + destinationVirtualFile.getName());
                if (copiedFile.exists()) {
                    System.out.println(
                            "file copied:" + copiedFile + " crc:" + FileUtils.checksumCRC32(copiedFile));
                } else {
                    //TODO error
                }

            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        } else {
            //TODO error
        }

    }
}