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:net.sf.jvifm.control.FindCommand.java

private IOFileFilter createFilter(String option, String argument) {

    boolean invert = false;

    if (option.equals("mtime")) {
        String[] arguments = getArgumentValueArray(argument);
        if (arguments.length == 2) {
            return new AndFileFilter(createAgeFilter(arguments[0]), createAgeFilter(arguments[1]));
        } else {//from w w w . j  a  v a  2  s  .  com
            return createAgeFilter(arguments[0]);
        }
    }
    if (option.equals("size")) {
        String[] arguments = getArgumentValueArray(argument);
        if (arguments.length == 2) {
            return new AndFileFilter(createSizeFilter(arguments[0]), createSizeFilter(arguments[1]));
        } else {
            return createSizeFilter(arguments[0]);
        }
    }
    if (option.equals("name")) {
        IOFileFilter filter = new WildcardFileFilter(argument, IOCase.INSENSITIVE);
        return (invert ? new NotFileFilter(filter) : filter);
    }
    if (option.equals("wholename")) {
        IOFileFilter filter = new PathFilter(argument.toString());
        return (invert ? new NotFileFilter(filter) : filter);
    }
    if (option.equals("text")) {
        IOFileFilter filter = new FileContentFilter(argument);
        return (invert ? new NotFileFilter(filter) : filter);
    }

    return null;
}

From source file:com.thoughtworks.go.server.GoServer.java

private List<File> getAddonJarFiles() {
    File addonsPath = new File(systemEnvironment.get(SystemEnvironment.ADDONS_PATH));
    if (!addonsPath.exists() || !addonsPath.canRead()) {
        return new ArrayList<>();
    }//from  www  .j  a  v  a  2  s.  com

    return new ArrayList<>(FileUtils.listFiles(addonsPath, new SuffixFileFilter("jar", IOCase.INSENSITIVE),
            FalseFileFilter.INSTANCE));
}

From source file:com.cloudbees.plugins.credentials.domains.HostnameSpecification.java

/**
 * {@inheritDoc}//from www .j av  a2 s.c om
 */
@NonNull
@Override
public Result test(@NonNull DomainRequirement requirement) {
    if (requirement instanceof HostnameRequirement) {
        String hostname = ((HostnameRequirement) requirement).getHostname();
        if (includes != null) {
            boolean isInclude = false;
            for (String include : includes.split("[,\\n ]")) {
                include = Util.fixEmptyAndTrim(include);
                if (include == null) {
                    continue;
                }
                if (FilenameUtils.wildcardMatch(hostname, include, IOCase.INSENSITIVE)) {
                    isInclude = true;
                    break;
                }
            }
            if (!isInclude) {
                return Result.NEGATIVE;
            }
        }
        if (excludes != null) {
            boolean isExclude = false;
            for (String exclude : excludes.split("[,\\n ]")) {
                exclude = Util.fixEmptyAndTrim(exclude);
                if (exclude == null) {
                    continue;
                }
                if (FilenameUtils.wildcardMatch(hostname, exclude, IOCase.INSENSITIVE)) {
                    isExclude = true;
                    break;
                }
            }
            if (isExclude) {
                return Result.NEGATIVE;
            }
        }
        return Result.PARTIAL;
    }
    return Result.UNKNOWN;
}

From source file:com.jkoolcloud.tnt4j.streams.custom.dirStream.DirWatchdog.java

/**
 * Creates default file filter matching file wildcard name pattern.
 *
 * @param fileWildcardName/*w w w.  j  av a2 s .  c  o  m*/
 *            file wildcard name pattern string
 *
 * @return created file filter
 */
public static FileFilter getDefaultFilter(String fileWildcardName) {
    if (StringUtils.isEmpty(fileWildcardName)) {
        return null;
    }

    IOFileFilter directories = FileFilterUtils.and(FileFilterUtils.directoryFileFilter(),
            HiddenFileFilter.VISIBLE);

    IOFileFilter files = FileFilterUtils.and(FileFilterUtils.fileFileFilter(),
            new WildcardFileFilter(fileWildcardName, IOCase.INSENSITIVE));

    IOFileFilter filter = FileFilterUtils.or(directories, files);

    return filter;
}

From source file:com.buisonje.tools.xmldbloader.XmlDataSetDBLoader.java

private void loadDataSetXMLFiles(IDatabaseConnection connection, DataFileLoader loader, File currentFileOrDir)
        throws DataSetException {
    final String currentFileOrDirPath = currentFileOrDir.getAbsolutePath();
    if (!currentFileOrDir.exists() || !currentFileOrDir.canRead()) {
        throw new IllegalArgumentException(String
                .format("Specified path \"%s\" does not exist or is not accessible.", currentFileOrDirPath));
    }/*from w ww  .  j a  v a 2 s. com*/
    if (currentFileOrDir.isDirectory()) {
        FileFilter fileFilter = new WildcardFileFilter("*.xml", IOCase.INSENSITIVE);
        File[] files = currentFileOrDir.listFiles(fileFilter);
        if (files == null) {
            LOGGER.error("Skipping invalid directory \"{}\".", currentFileOrDirPath);
            return;
        }
        if (files.length < 1) {
            LOGGER.warn("Directory \"{}\" contains no XML files. Skipping this directory.",
                    currentFileOrDirPath);
            return;
        }
        for (final File xmlFile : files) {
            if (xmlFile.isDirectory()) {
                LOGGER.warn(
                        "Specified directory \"{}\" contains a subdirectory called \"{}\". Will *not* recurse.",
                        currentFileOrDir.getAbsolutePath(), xmlFile.getAbsolutePath());
            } else {
                loadDataSetXMLFile(connection, loader, xmlFile);
            }
        }
    } else {
        loadDataSetXMLFile(connection, loader, currentFileOrDir);
    }

}

From source file:cross.io.InputDataFactory.java

/**
 * Create a collection of files from the given string resource paths.
 *
 * @param input the string resource paths
 * @return a collection of files/*from w ww.  jav  a 2  s.  c  o  m*/
 */
@Override
public Collection<File> getInputFiles(String[] input) {
    LinkedHashSet<File> files = new LinkedHashSet<>();
    for (String inputString : input) {
        log.debug("Processing input string {}", inputString);
        //separate wildcards from plain files
        String name = FilenameUtils.getName(inputString);
        boolean isWildcard = name.contains("?") || name.contains("*");
        String fullPath = FilenameUtils.getFullPath(inputString);
        File path = new File(fullPath);
        File baseDirFile = new File(this.basedir);
        if (!baseDirFile.exists()) {
            throw new ExitVmException("Input base directory '" + baseDirFile + "' does not exist!");
        }
        if (!baseDirFile.isDirectory()) {
            throw new ExitVmException("Input base directory '" + baseDirFile + "' is not a directory!");
        }
        log.debug("Path is absolute: {}", path.isAbsolute());
        //identify absolute and relative files
        if (!path.isAbsolute()) {
            log.info("Resolving relative file against basedir: {}", this.basedir);
            path = new File(this.basedir, fullPath);
        }
        //normalize filenames
        fullPath = FilenameUtils.normalize(path.getAbsolutePath());
        log.debug("After normalization: {}", fullPath);
        IOFileFilter dirFilter = this.recurse ? TrueFileFilter.INSTANCE : null;
        if (isWildcard) {
            log.debug("Using wildcard matcher for {}", name);
            files.addAll(FileUtils.listFiles(new File(fullPath),
                    new WildcardFileFilter(name, IOCase.INSENSITIVE), dirFilter));
        } else {
            log.debug("Using name for {}", name);
            File f = new File(fullPath, name);
            if (!f.exists()) {
                throw new ExitVmException("Input file '" + f + "' does not exist!");
            }
            files.add(f);
        }
    }
    return files;
}

From source file:de.cenote.jasperstarter.App.java

private void compile(Config config) {
    IllegalArgumentException error = null;
    File input = new File(config.getInput());
    if (input.isFile()) {
        try {//from w ww.j a v a  2  s  .  co  m
            Report report = new Report(config, input);
            report.compileToFile();
        } catch (IllegalArgumentException ex) {
            error = ex;
        }
    } else if (input.isDirectory()) {
        // compile all .jrxml files in this directory
        FileFilter fileFilter = new WildcardFileFilter("*.jrxml", IOCase.INSENSITIVE);
        File[] files = input.listFiles(fileFilter);
        for (File file : files) {
            try {
                System.out.println("Compiling: \"" + file + "\"");
                Report report = new Report(config, file);
                report.compileToFile();
            } catch (IllegalArgumentException ex) {
                error = ex;
            }
        }
    } else {
        error = new IllegalArgumentException("Error: not a file: " + input.getName());
    }
    if (error != null) {
        throw error;
    }
}

From source file:com.cloudbees.plugins.credentials.domains.HostnamePortSpecification.java

/**
 * {@inheritDoc}/*w  w w  . j  a  v a  2 s . c o  m*/
 */
@NonNull
@Override
public Result test(@NonNull DomainRequirement requirement) {
    if (requirement instanceof HostnamePortRequirement) {
        String hostPort = ((HostnamePortRequirement) requirement).getHostname() + ":"
                + ((HostnamePortRequirement) requirement).getPort();
        if (includes != null) {
            boolean isInclude = false;
            for (String include : includes.split("[,\\n ]")) {
                include = Util.fixEmptyAndTrim(include);
                if (include == null) {
                    continue;
                }
                if (include.indexOf(':') == -1) {
                    include = include + ":*";
                }
                if (FilenameUtils.wildcardMatch(hostPort, include, IOCase.INSENSITIVE)) {
                    isInclude = true;
                    break;
                }
            }
            if (!isInclude) {
                return Result.NEGATIVE;
            }
        }
        if (excludes != null) {
            boolean isExclude = false;
            for (String exclude : excludes.split("[,\\n ]")) {
                exclude = Util.fixEmptyAndTrim(exclude);
                if (exclude == null) {
                    continue;
                }
                if (exclude.indexOf(':') == -1) {
                    exclude = exclude + ":*";
                }
                if (FilenameUtils.wildcardMatch(hostPort, exclude, IOCase.INSENSITIVE)) {
                    isExclude = true;
                    break;
                }
            }
            if (isExclude) {
                return Result.NEGATIVE;
            }
        }
    } else if (requirement instanceof HostnameRequirement) {
        // if the requirement is only for a hostname we can still match some of the spec.
        String hostname = ((HostnameRequirement) requirement).getHostname();
        if (includes != null) {
            boolean isInclude = false;
            for (String include : includes.split("[,\\n ]")) {
                include = Util.fixEmptyAndTrim(include);
                if (include == null) {
                    continue;
                }
                int index = include.indexOf(":");
                if (index != -1) {
                    include = include.substring(0, index);
                }
                if (FilenameUtils.wildcardMatch(hostname, include, IOCase.INSENSITIVE)) {
                    isInclude = true;
                    break;
                }
            }
            if (!isInclude) {
                return Result.NEGATIVE;
            }
        }
        if (excludes != null) {
            boolean isExclude = false;
            for (String exclude : excludes.split("[,\\n ]")) {
                exclude = Util.fixEmptyAndTrim(exclude);
                if (exclude == null) {
                    continue;
                }
                int index = exclude.indexOf(":");
                if (index != -1) {
                    exclude = exclude.substring(0, index);
                }
                if (FilenameUtils.wildcardMatch(hostname, exclude, IOCase.INSENSITIVE)) {
                    isExclude = true;
                    break;
                }
            }
            if (isExclude) {
                return Result.NEGATIVE;
            }
        }
    }
    return Result.UNKNOWN;
}

From source file:com.silverpeas.look.SilverpeasLook.java

private String getWallPaperURL(String spaceId) {
    String id = getShortSpaceId(spaceId);
    String basePath = getSpaceBasePath(id);
    File dir = new File(basePath);
    if (dir.exists() && dir.isDirectory()) {
        Collection<File> wallpapers = FileUtils.listFiles(dir,
                FileFilterUtils.prefixFileFilter("wallPaper", IOCase.INSENSITIVE), null);
        for (File wallpaper : wallpapers) {
            if (wallpaper.isFile() && FileUtil.isImage(wallpaper.getName())) {
                return getURLOfElement(id, wallpaper.getName());
            }// www .ja va2 s . c  o  m
        }
    }
    return null;
}

From source file:modmanager.backend.Modification.java

private void load(File path) {
    logger.log(Level.INFO, "Loading modification from {0}", path.getAbsolutePath());

    if (!path.isDirectory()) {
        return;/*w  w  w .  j av  a2  s . com*/
    }

    /**
     * Precheck: dir empty? (failed extraction)
     */
    if (path.list().length == 0) {
        path.delete();
        return;
    }

    /**
     * Precheck: archive ghost dir?
     */
    {
        File[] entries = path.listFiles();

        if (entries.length == 1) {
            File one = entries[0];

            if (one.isDirectory()) {
                if (!one.getName().equalsIgnoreCase("data")) {
                    try {
                        logger.log(Level.INFO,
                                "Moving directory, because someone decided it's good to pack all data into a sub directory ...");

                        /**
                         * It's a directory. Change filesystem by
                         * reparenting
                         */
                        File tmp = new File(path.getAbsolutePath() + ".tmp");

                        FileUtils.moveDirectory(one, tmp);
                        FileUtils.deleteDirectory(path);
                        FileUtils.moveDirectory(tmp, path);
                    } catch (IOException ex) {
                        logger.log(Level.SEVERE, ex.getMessage());

                        return;
                    }
                }
            }
        }
    }

    this.directory = path;

    /**
     * Read name
     */
    this.name = path.getName();

    /**
     * Wizard indicates
     */
    if ((new File(path, "Wizard.txt")).exists()) {
        this.type = Type.MULTIOPTION;
    } else {
        this.type = Type.MULTIOPTION;

        for (File sub : path.listFiles()) {
            if (FilenameUtils.wildcardMatch(sub.getName(), "*.bsa", IOCase.INSENSITIVE)) {
                this.type = Type.SIMPLE;
                break;
            } else if (FilenameUtils.wildcardMatch(sub.getName(), "*.esp", IOCase.INSENSITIVE)) {
                this.type = Type.SIMPLE;
                break;
            } else if (FilenameUtils.wildcardMatch(sub.getName(), "Meshes", IOCase.INSENSITIVE)) {
                this.type = Type.SIMPLE;
                break;
            } else if (FilenameUtils.wildcardMatch(sub.getName(), "Textures", IOCase.INSENSITIVE)) {
                this.type = Type.SIMPLE;
                break;
            } else if (FilenameUtils.wildcardMatch(sub.getName(), "data", IOCase.INSENSITIVE)) {
                this.type = Type.SIMPLE;
                break;
            }
        }
    }

    logger.log(Level.INFO, "... mod type detected: {0}", this.type);

    /**
     * OK, load the mod types from given type
     */
    switch (this.type) {
    /**
     * This is intended!
     */
    case MULTIOPTION: {
        for (File sub : path.listFiles()) {
            if (sub.isDirectory() && !sub.getName().equalsIgnoreCase("fomod")
                    && !sub.getName().toLowerCase().contains("readme")
                    && !sub.getName().toLowerCase().contains("manual")) {
                ModificationOption opt = new ModificationOption(this, sub);

                if (opt.getFileCount() != 0) {
                    options.put(opt.getName(), opt);
                }
            }
        }
    }
        break;
    case SIMPLE:

    {
        //Create new option based on modification path
        ModificationOption opt = new ModificationOption(this, path);

        if (opt.getFileCount() != 0) {
            options.put(opt.getName(), opt);
        }
    }

        break;
    }

    /**
     * Load screenshots
     */
    for (File file : getScreenshotImages()) {
        status.addScreenshotImage(file);
    }

    if (!options.isEmpty()) {
        loaded = true;
    } else {
        logger.log(Level.WARNING, "Ignoring {0}: Empty!", name);
    }

}