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:com.tekstosense.opennlp.config.ModelLoaderConfig.java

/**
 * Gets the models. This method is used if ModelPath is passed as parameter.
 * /* w w w.  j a v  a  2  s.  c  o  m*/
 *
 * @return the models
 */
public static String[] getModels(String modelDirectory) {
    File dir = new File(modelDirectory);

    LOG.info("Loading Models from... " + dir.getAbsolutePath());
    List<String> models = new ArrayList<>();
    String[] modelNames = getModelNames();

    List<String> wildCardPath = Arrays.stream(modelNames).map(model -> {
        return "en-ner-" + model + "*.bin";
    }).collect(Collectors.toList());

    FileFilter fileFilter = new WildcardFileFilter(wildCardPath, IOCase.INSENSITIVE);
    List<String> filePath = Arrays.asList(dir.listFiles(fileFilter)).stream()
            .map(file -> file.getAbsolutePath()).collect(Collectors.toList());
    return filePath.toArray(new String[filePath.size()]);
}

From source file:com.jkoolcloud.tnt4j.streams.inputs.HdfsFileLineStream.java

/**
 * Searches for files matching name pattern. Name pattern also may contain path of directory, where file search
 * should be performed, e.g., C:/Tomcat/logs/localhost_access_log.*.txt. If no path is defined (just file name
 * pattern) then files are searched in {@code System.getProperty("user.dir")}. Files array is ordered by file create
 * timestamp in descending order./*from w  w w.  j av a  2  s.  com*/
 *
 * @param path
 *            path of file
 * @param fs
 *            file system
 *
 * @return array of found files paths.
 * @throws IOException
 *             if files can't be listed by file system.
 *
 * @see FileSystem#listStatus(Path, PathFilter)
 * @see FilenameUtils#wildcardMatch(String, String, IOCase)
 */
public static Path[] searchFiles(Path path, FileSystem fs) throws IOException {
    FileStatus[] dir = fs.listStatus(path.getParent(), new PathFilter() {
        @Override
        public boolean accept(Path path) {
            String name = path.getName();
            return FilenameUtils.wildcardMatch(name, "*", IOCase.INSENSITIVE); // NON-NLS
        }
    });

    Path[] activityFiles = new Path[dir == null ? 0 : dir.length];
    if (dir != null) {
        Arrays.sort(dir, new Comparator<FileStatus>() {
            @Override
            public int compare(FileStatus o1, FileStatus o2) {
                return Long.valueOf(o1.getModificationTime()).compareTo(o2.getModificationTime()) * (-1);
            }
        });

        for (int i = 0; i < dir.length; i++) {
            activityFiles[i] = dir[i].getPath();
        }
    }

    return activityFiles;
}

From source file:modmanager.backend.ModificationOption.java

private void load(File path) {
    logger.log(Level.FINE, "Modification option requested for {0}", path.getAbsolutePath());

    /**//from  ww w . ja v  a 2s  .  co  m
     * Set name
     */
    name = path.getName();

    /**
     * Make compatible
     */
    makeUnixCompatible(path);

    /**
     * Declare if data rooted or main dir rooted
     */
    if ((new File(path, "Data")).exists()) {
        rootDirectory = "";
    } else {
        rootDirectory = "Data";
    }

    /**
     * Look in files
     */
    for (File file : FileUtils.listFiles(path, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)) {
        if (!file.isDirectory()) {
            if (file.getParentFile().getName().equalsIgnoreCase("fomod")) {
                continue;
            } else if (FilenameUtils.wildcardMatch(file.getName(), "*.txt", IOCase.INSENSITIVE)) {
                continue;
            } else if (FilenameUtils.wildcardMatch(file.getName(), "*.rtf", IOCase.INSENSITIVE)) {
                continue;
            } else if (FilenameUtils.wildcardMatch(file.getName(), "*.pdf", IOCase.INSENSITIVE)) {
                continue;
            } else if (FilenameUtils.wildcardMatch(file.getName(), "*.jskmm_status", IOCase.INSENSITIVE)) {
                continue;
            }

            getFiles().add(file);

            logger.log(Level.FINE, "... added {0} to option", Util.relativePath(path, file));
        }
    }
}

From source file:it.geosolutions.geobatch.actions.commons.CollectorAction.java

/**
 * Removes TemplateModelEvents from the queue and put
 *//*from  w  w  w .j a  va2s .  c  o  m*/
public Queue<EventObject> execute(Queue<EventObject> events) throws ActionException {

    listenerForwarder.started();
    listenerForwarder.setTask("build the output absolute file name");

    // return
    final Queue<EventObject> ret = new LinkedList<EventObject>();

    listenerForwarder.setTask("Building/getting the root data structure");

    if (conf.getWildcard() == null) {
        LOGGER.warn("Null wildcard: using default\'*\'");
        conf.setWildcard("*");
    }

    it.geosolutions.tools.io.file.Collector collector = new it.geosolutions.tools.io.file.Collector(
            new WildcardFileFilter(conf.getWildcard(), IOCase.INSENSITIVE), conf.getDeep());
    while (!events.isEmpty()) {

        final EventObject event = events.remove();
        if (event == null) {
            // TODO LOG
            continue;
        }
        File source = null;
        if (event.getSource() instanceof File) {
            source = ((File) event.getSource());
        }

        if (source == null || !source.exists()) {
            // LOG
            continue;
        }
        listenerForwarder.setTask("Collecting from" + source);

        List<File> files = collector.collect(source);
        if (files == null) {
            return ret;
        }
        for (File file : files) {
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Collected file: " + file);
            }
            ret.add(new FileSystemEvent(file, FileSystemEventType.FILE_ADDED));
        }

    }
    listenerForwarder.completed();
    return ret;
}

From source file:com.moneydance.modules.features.importlist.io.FileAdmin.java

public FileAdmin(final String baseDirectory, final FeatureModuleContext argContext) {
    this.localizable = Helper.INSTANCE.getLocalizable();
    this.context = argContext;
    if (SystemUtils.IS_OS_MAC) {
        this.directoryChooser = new MacOSDirectoryChooser(baseDirectory);
    } else {/*from   w  w w .  j  a  va  2  s. c  o m*/
        this.directoryChooser = new DefaultDirectoryChooser(baseDirectory);
    }
    this.directoryValidator = DirectoryValidator.INSTANCE;
    this.transactionFileFilter = new SuffixFileFilter(
            Helper.INSTANCE.getSettings().getTransactionFileExtensions(), IOCase.INSENSITIVE);
    this.textFileFilter = new SuffixFileFilter(Helper.INSTANCE.getSettings().getTextFileExtensions(),
            IOCase.INSENSITIVE);
    this.readableFileFilter = FileFilterUtils.and(CanReadFileFilter.CAN_READ,
            FileFilterUtils.or(this.transactionFileFilter, this.textFileFilter));

    this.listener = new TransactionFileListener();
    this.listener.addObserver(this);
    this.monitor = new FileAlterationMonitor(Helper.INSTANCE.getSettings().getMonitorInterval());

    this.files = Collections.synchronizedList(new ArrayList<File>());
}

From source file:net.sf.jvifm.util.AutoCompleteUtil.java

public static List<File> getFileCompleteList(String pwd, String path, boolean onlyDir) {
    List<File> list = new ArrayList<File>();
    String fileName = new File(path).getName();

    if (path.endsWith(":"))
        return null;

    File file = new File(FilenameUtils.concat(pwd, path));

    File pwdFile = null;/*  w w  w . ja  va 2  s.c o  m*/
    pwdFile = file;
    if (path.endsWith(File.separator) || path.trim().equals("")) {
        pwdFile = file;
    } else {
        if (file.getParent() == null)
            return null;
        pwdFile = new File(file.getParent());
    }
    if (!pwdFile.exists())
        return null;
    File[] files = pwdFile.listFiles((FileFilter) Util.getDefaultFileFilter());

    if (files == null || files.length <= 0)
        return null;
    boolean lowerCase = false;
    if (fileName.toLowerCase().equals(fileName)) {
        lowerCase = true;
    }
    for (int i = 0; i < files.length; i++) {
        String tmpFileName = files[i].getName();
        if (lowerCase)
            tmpFileName = tmpFileName.toLowerCase();
        if (tmpFileName.startsWith(fileName) || path.endsWith(File.separator)
                || FilenameUtils.wildcardMatch(tmpFileName, fileName, IOCase.INSENSITIVE))
            if (onlyDir) {
                if (files[i].isDirectory())
                    list.add(files[i]);
            } else {
                list.add(files[i]);
            }
    }
    if (list.size() <= 0)
        return null;
    return list;
}

From source file:com.thoughtworks.go.config.rules.AbstractDirective.java

protected boolean matchesResource(String resource) {
    if (equalsIgnoreCase("*", this.resource)) {
        return true;
    }//  w w w .java  2s.c om

    return FilenameUtils.wildcardMatch(resource, this.resource, IOCase.INSENSITIVE);
}

From source file:com.jkoolcloud.tnt4j.streams.configure.sax.ConfigParserHandlerTest.java

protected void validateConfigs(File samplesDir, String configFileWildcard, boolean checkStreams,
        List<String> skipFiles) throws Exception {
    Collection<File> sampleConfigurations = FileUtils.listFiles(samplesDir,
            FileFilterUtils.asFileFilter(
                    (FilenameFilter) new WildcardFileFilter(configFileWildcard, IOCase.INSENSITIVE)),
            TrueFileFilter.INSTANCE);/*from w w  w  .ja  v a2 s.  c om*/

    Collection<File> sampleConfigurationsFiltered = new ArrayList<>(sampleConfigurations);
    if (CollectionUtils.isNotEmpty(skipFiles)) {
        for (File sampleConfiguration : sampleConfigurations) {
            for (String skipFile : skipFiles) {
                if (sampleConfiguration.getAbsolutePath().contains(skipFile))
                    sampleConfigurationsFiltered.remove(sampleConfiguration);
            }
        }
    }

    for (File sampleConfiguration : sampleConfigurationsFiltered) {
        System.out.println("Reading configuration file: " + sampleConfiguration.getAbsolutePath()); // NON-NLS
        Reader testReader = new FileReader(sampleConfiguration);
        SAXParserFactory parserFactory = SAXParserFactory.newInstance();
        SAXParser parser = parserFactory.newSAXParser();
        ConfigParserHandler hndlr = new ConfigParserHandler();
        parser.parse(new InputSource(testReader), hndlr);

        assertNotNull("Parsed streams config data is null", hndlr.getStreamsConfigData());
        boolean parseable = true;
        if (checkStreams) {
            assertTrue("No configured streams", hndlr.getStreamsConfigData().isStreamsAvailable());

            parseable = false;
            for (TNTInputStream<?, ?> s : hndlr.getStreamsConfigData().getStreams()) {
                if (s instanceof TNTParseableInputStream) {
                    parseable = true;
                    break;
                }
            }
        }
        if (parseable) {
            assertTrue("No configured parsers", hndlr.getStreamsConfigData().isParsersAvailable());
        }

        Utils.close(testReader);
    }
}

From source file:eu.europa.ejusticeportal.dss.applet.model.service.FileSeeker.java

/**
 * Search for a library Path./*from  w  ww  .  j a  v a  2 s.c  o m*/
 * A library path can be configured with a wild card, similar to: "root/sub/filename.extension" where sub,
 * filename and extension can contain one ore more wildcard "*".
 * 
 * @param libraryPath the Library Path in which the search will be performed.
 * @return the set of files found.
 */
public Set<String> search(String libraryPath) {
    LOG.log(Level.FINE, "searching for library path: {0}", libraryPath);
    Set<String> result = new HashSet<String>();

    TokenizedLibraryPath tokenLibPath = new TokenizedLibraryPath();
    tokenLibPath.tokenize(libraryPath);
    LOG.log(Level.FINE, "tokenized={0}", tokenLibPath.toString());
    WildcardFileFilter fileFilter = new WildcardFileFilter(tokenLibPath.getFileName(), IOCase.INSENSITIVE);
    final File rootDir = new File(tokenLibPath.getRootDirPath());

    if (rootDir.exists()) {
        LOG.log(Level.FINE, "Existing root directory: {0}", rootDir.getAbsolutePath());
        final IOFileFilter dirFilter;
        if (tokenLibPath.getWildcardSubDirPath().isEmpty()) {
            dirFilter = null;
        } else {
            dirFilter = new WildcardDirectoryFilter(rootDir, tokenLibPath.getWildcardSubDirPath());
        }
        result.addAll(search(fileFilter, rootDir, dirFilter));
    }
    return result;
}

From source file:com.qwazr.utils.WildcardMatcher.java

/**
 * Case insensitive match//from   w  ww  .ja  v a 2  s .  com
 *
 * @param name the string to test
 * @return true if the name matches the pattern
 */
public boolean match(String name) {
    return match(name, IOCase.INSENSITIVE);
}