Example usage for org.apache.commons.io IOCase INSENSITIVE

List of usage examples for org.apache.commons.io IOCase INSENSITIVE

Introduction

In this page you can find the example usage for org.apache.commons.io IOCase INSENSITIVE.

Prototype

IOCase INSENSITIVE

To view the source code for org.apache.commons.io IOCase INSENSITIVE.

Click Source Link

Document

The constant for case insensitive regardless of operating system.

Usage

From source file:io.manasobi.utils.FileUtils.java

/**
 *  ? ?  ?? File ?  ./*from   w w w.j a  v a  2s  . c o  m*/
 * 
 * @param dir  
 * @param recursive  ?? ? ??   
 * @param extList ? ? 
 * @return  ? ?  ??  File ? 
 */
public static File[] listFilesExcludeExt(String dir, boolean recursive, String... extList) {

    IOFileFilter suffixFileFilters = new SuffixFileFilter(extList, IOCase.INSENSITIVE);
    IOFileFilter excludeExtFilter = FileFilterUtils.notFileFilter(FileFilterUtils.or(suffixFileFilters));

    Collection<File> resultFiles = org.apache.commons.io.FileUtils.listFiles(new File(dir), excludeExtFilter,
            TrueFileFilter.INSTANCE);

    return org.apache.commons.io.FileUtils.convertFileCollectionToFileArray(resultFiles);
}

From source file:nl.armatiek.xslweb.configuration.WebApp.java

private void initFileAlterationObservers() {
    monitor = new FileAlterationMonitor(3000);

    if (!developmentMode) {
        IOFileFilter xslFiles = FileFilterUtils.and(FileFilterUtils.fileFileFilter(),
                new SuffixFileFilter(new String[] { ".xsl", ".xslt" }, IOCase.INSENSITIVE));
        FileAlterationObserver xslObserver = new FileAlterationObserver(new File(homeDir, "xsl"),
                FileFilterUtils.or(FileFilterUtils.directoryFileFilter(), xslFiles));
        xslObserver.addListener(new FileAlterationListenerAdaptor() {

            @Override/*  w w  w  .  j  av  a2  s .c  om*/
            public void onFileChange(File file) {
                onFileChanged(file, "Change in XSL stylesheet \"%s\" detected. Reloading webapp ...");
            }

            @Override
            public void onFileDelete(File file) {
                onFileChanged(file, "Deletion of XSL stylesheet \"%s\" detected. Reloading webapp ...");
            }

        });
        monitor.addObserver(xslObserver);
    }

    IOFileFilter jarAndClassFiles = FileFilterUtils.and(FileFilterUtils.fileFileFilter(),
            new SuffixFileFilter(new String[] { ".jar", ".class" }, IOCase.INSENSITIVE));
    FileAlterationObserver classObserver = new FileAlterationObserver(new File(homeDir, "lib"),
            FileFilterUtils.or(FileFilterUtils.directoryFileFilter(), jarAndClassFiles));
    classObserver.addListener(new FileAlterationListenerAdaptor() {

        @Override
        public void onFileCreate(File file) {
            onFileChanged(file, "New plugin jar or class file \"%s\" detected. Reloading webapp ...");
        }

        @Override
        public void onFileChange(File file) {
            onFileChanged(file, "Change in plugin jar or class file \"%s\" detected. Reloading webapp ...");
        }

        @Override
        public void onFileDelete(File file) {
            onFileChanged(file, "Deletion of plugin jar or class file \"%s\" detected. Reloading webapp ...");
        }

    });
    monitor.addObserver(classObserver);
}

From source file:nl.armatiek.xslweb.saxon.configuration.XSLWebConfiguration.java

private void addCustomExtensionFunctions(WebApp webApp) throws Exception {
    File libDir = new File(webApp.getHomeDir(), "lib");
    if (!libDir.isDirectory()) {
        return;/*w  w w. j  a  v a2 s  .c  o  m*/
    }
    List<File> classPath = new ArrayList<File>();
    classPath.addAll(
            FileUtils.listFiles(libDir, new WildcardFileFilter("*.jar"), DirectoryFileFilter.DIRECTORY));
    if (classPath.isEmpty() && !XSLWebUtils.hasSubDirectories(libDir)) {
        return;
    }
    classPath.add(libDir);
    Collection<File> saxonJars = FileUtils.listFiles(new File(Context.getInstance().getWebInfDir(), "lib"),
            new WildcardFileFilter("*saxon*.jar", IOCase.INSENSITIVE), FalseFileFilter.INSTANCE);
    classPath.addAll(saxonJars);

    logger.info("Initializing custom extension functions ...");

    ClassFinder finder = new ClassFinder();
    finder.add(classPath);

    ClassFilter filter = new AndClassFilter(
            // Must extend ExtensionFunctionDefinition class
            new SubclassClassFilter(ExtensionFunctionDefinition.class),
            // Must not be abstract
            new NotClassFilter(new AbstractClassFilter()));

    Collection<ClassInfo> foundClasses = new ArrayList<ClassInfo>();
    finder.findClasses(foundClasses, filter);
    if (foundClasses.isEmpty()) {
        logger.info("No custom extension functions found.");
        return;
    }
    ClassLoaderBuilder builder = new ClassLoaderBuilder();
    builder.add(classPath);
    ClassLoader classLoader = builder.createClassLoader();
    for (ClassInfo classInfo : foundClasses) {
        String className = classInfo.getClassName();
        if (initializer.isFunctionRegistered(className) || saxonJars.contains(classInfo.getClassLocation())) {
            continue;
        }
        Class<?> clazz = classLoader.loadClass(className);
        logger.info(String.format("Adding custom extension function class \"%s\" ...", className));
        registerExtensionFunction((ExtensionFunctionDefinition) clazz.newInstance());
    }
}

From source file:ocropusgtedit.mainFrame.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    /** INITIALIZAZION of GT-Editing process
     *  1. Direcotory files to img and txt Arrays
     *  2. Loading of first set of img/txt
     *//*from   w w w  . j a va2 s  . c om*/
    globalCounter = 0;
    GTTextField.setText("");
    try {

        String workDIR = GTWorkDirField.getText();
        //System.out.println(workDIR);

        File f = new File(workDIR);
        //File[] fileArray = f.listFiles();
        txtFilesArray = f.listFiles((FileFilter) new SuffixFileFilter(".txt", IOCase.INSENSITIVE));
        imgFilesArray = f.listFiles((FileFilter) new SuffixFileFilter(".png", IOCase.INSENSITIVE));
        Arrays.sort(txtFilesArray);
        Arrays.sort(imgFilesArray);

        img = ImageIO.read(imgFilesArray[globalCounter]);
        Icon ico = new ImageIcon(
                Scalr.resize(img, Scalr.Method.SPEED, Scalr.Mode.FIT_TO_HEIGHT, 50, Scalr.OP_ANTIALIAS));
        GTLabel.setIcon(ico);

        BufferedReader in = new BufferedReader(
                new InputStreamReader(new FileInputStream(txtFilesArray[globalCounter]), "UTF8"));
        String str;

        while ((str = in.readLine()) != null) {
            System.out.println(str);
            GTTextField.setText(GTTextField.getText() + str);
        }

        in.close();

    } catch (IOException ex) {
        Logger.getLogger(mainFrame.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:org.angcms.util.ResourceUtils.java

public static List<String> getFilesName(String directory, List<String> extensions) {
    File rootDir = new File(getRealPath(directory));
    IOFileFilter filesFilter = new SuffixFileFilter(extensions, IOCase.INSENSITIVE);
    IOFileFilter notDirectory = new NotFileFilter(DirectoryFileFilter.INSTANCE);
    FilenameFilter fileFilter = new AndFileFilter(filesFilter, notDirectory);
    String[] resultFiles = rootDir.list(fileFilter);
    Arrays.sort(resultFiles);//from w  ww . j a v  a2  s  .  com
    if (resultFiles.length > 0) {
        return Arrays.asList(resultFiles);
    }
    return new ArrayList<String>();
}

From source file:org.apache.atlas.authorize.simple.SimpleAtlasAuthorizer.java

private boolean isMatch(String resource, List<String> policyValues) {
    if (isDebugEnabled) {
        LOG.debug("==> SimpleAtlasAuthorizer isMatch");
    }/*from   w ww  . ja  v a 2 s .c  om*/
    boolean isMatchAny = resourceMatchHelper(policyValues);
    boolean isMatch = false;
    boolean allValuesRequested = isAllValuesRequested(resource);

    if (allValuesRequested || isMatchAny) {
        isMatch = isMatchAny;
    } else {
        for (String policyValue : policyValues) {
            if (policyValue.contains("*")) {
                isMatch = optIgnoreCase ? FilenameUtils.wildcardMatch(resource, policyValue, IOCase.INSENSITIVE)
                        : FilenameUtils.wildcardMatch(resource, policyValue, IOCase.SENSITIVE);
            } else {
                isMatch = optIgnoreCase ? StringUtils.equalsIgnoreCase(resource, policyValue)
                        : StringUtils.equals(resource, policyValue);
            }
            if (isMatch) {
                break;
            }
        }
    }

    if (!isMatch) {
        if (isDebugEnabled) {
            StringBuilder sb = new StringBuilder();
            sb.append("[");
            for (String policyValue : policyValues) {
                sb.append(policyValue);
                sb.append(" ");
            }
            sb.append("]");

            LOG.debug("AtlasDefaultResourceMatcher.isMatch returns FALSE, (resource={}, policyValues={})",
                    resource, sb.toString());
        }

    }

    if (isDebugEnabled) {
        LOG.debug("<== SimpleAtlasAuthorizer isMatch({}): {}", resource, isMatch);
    }

    return isMatch;
}

From source file:org.apache.atlas.authorize.SimpleAtlasAuthorizer.java

private boolean isMatch(String resource, List<String> policyValues) {
    if (isDebugEnabled) {
        LOG.debug("<== SimpleAtlasAuthorizer isMatch");
    }/*w  w  w  .  j  ava  2s  .c o  m*/
    boolean isMatchAny = resourceMatchHelper(policyValues);
    boolean isMatch = false;
    boolean allValuesRequested = isAllValuesRequested(resource);

    if (allValuesRequested || isMatchAny) {
        isMatch = isMatchAny;
    } else {
        for (String policyValue : policyValues) {
            if (policyValue.contains("*")) {
                isMatch = optIgnoreCase ? FilenameUtils.wildcardMatch(resource, policyValue, IOCase.INSENSITIVE)
                        : FilenameUtils.wildcardMatch(resource, policyValue, IOCase.SENSITIVE);
            } else {
                isMatch = optIgnoreCase ? StringUtils.equalsIgnoreCase(resource, policyValue)
                        : StringUtils.equals(resource, policyValue);
            }
            if (isMatch) {
                break;
            }
        }
    }

    if (isMatch == false) {

        if (isDebugEnabled) {
            StringBuilder sb = new StringBuilder();
            sb.append("[");
            for (String policyValue : policyValues) {
                sb.append(policyValue);
                sb.append(" ");
            }
            sb.append("]");

            LOG.debug("AtlasDefaultResourceMatcher.isMatch returns FALSE, (resource=" + resource
                    + ", policyValues=" + sb.toString() + ")");
        }

    }

    if (isDebugEnabled) {
        LOG.debug("==> SimpleAtlasAuthorizer isMatch(" + resource + "): " + isMatch);
    }

    return isMatch;
}

From source file:org.apache.fop.fonts.autodetect.FontFileFinder.java

/**
 * Font file filter.  Currently searches for files with .ttf, .ttc, .otf, and .pfb extensions.
 * @return IOFileFilter font file filter
 */// w  w  w  .  j av  a  2 s.  co  m
protected static IOFileFilter getFileFilter() {
    return FileFilterUtils.andFileFilter(FileFilterUtils.fileFileFilter(),
            new WildcardFileFilter(new String[] { "*.ttf", "*.otf", "*.pfb", "*.ttc" }, IOCase.INSENSITIVE));
}

From source file:org.apache.log.extractor.App.java

private List<File> getLogFiles(String[] logLocations) throws IOException {
    final String logFileNamePattern = config.getString("log.oozie.filename.pattern");
    Set<File> uniqueFiles = new HashSet<File>();
    for (String oneLocation : logLocations) {
        File file = new File(oneLocation);
        if (!file.isFile()) {
            final Collection listFiles = FileUtils.listFiles(file,
                    new WildcardFileFilter(logFileNamePattern, IOCase.INSENSITIVE), TrueFileFilter.INSTANCE);
            uniqueFiles.addAll(listFiles);
        } else {//  w  ww  . j a v  a2s . c o  m
            uniqueFiles.add(file);
        }
    }
    return new ArrayList<File>(uniqueFiles);
}

From source file:org.apache.ranger.plugin.resourcematcher.RangerAbstractResourceMatcher.java

@Override
boolean isMatch(String resourceValue, Map<String, Object> evalContext) {
    return FilenameUtils.wildcardMatch(resourceValue, getExpandedValue(evalContext), IOCase.INSENSITIVE);
}