Example usage for org.apache.commons.io.filefilter FileFilterUtils notFileFilter

List of usage examples for org.apache.commons.io.filefilter FileFilterUtils notFileFilter

Introduction

In this page you can find the example usage for org.apache.commons.io.filefilter FileFilterUtils notFileFilter.

Prototype

public static IOFileFilter notFileFilter(IOFileFilter filter) 

Source Link

Document

Returns a filter that NOTs the specified filter.

Usage

From source file:net.landora.videoplayer.files.GeneralDirectoryMenu.java

@Override
protected void refreshImpl() {
    links = new ArrayList<MenuLink>();

    File[] children = dir.listFiles((FileFilter) FileFilterUtils.directoryFileFilter());
    if (children != null && children.length > 0) {
        Arrays.sort(children, new FileSorter());
        for (File child : children) {
            links.add(new MenuLink(Icon.Folder, child.getName(), new GeneralDirectoryMenu(child)));
        }//from w  ww.j  a  v  a2s  .com
    }

    children = dir.listFiles((FileFilter) FileFilterUtils.notFileFilter(FileFilterUtils.directoryFileFilter()));
    if (children != null & children.length != 0) {
        Arrays.sort(children, new FileSorter());

        for (File child : children) {
            if (child.isHidden() || !child.isFile() || !ExtensionUtils.isVideoExtension(child)) {
                continue;
            }

            links.add(new MenuLink(Icon.File, child.getName(), new PlayFileAction(child)));
        }
    }
}

From source file:com.mirth.connect.cli.launcher.CommandLineLauncher.java

private static void addManifestToClasspath(ManifestEntry[] manifestEntries, List<URL> urls) throws Exception {
    for (ManifestEntry manifestEntry : manifestEntries) {
        File manifestEntryFile = new File(manifestEntry.getName());

        if (manifestEntryFile.exists()) {
            if (manifestEntryFile.isDirectory()) {
                ManifestDirectory manifestDir = (ManifestDirectory) manifestEntry;
                IOFileFilter fileFilter = null;

                if (manifestDir.getExcludes().length > 0) {
                    fileFilter = FileFilterUtils.and(FileFilterUtils.fileFileFilter(),
                            FileFilterUtils.notFileFilter(new NameFileFilter(manifestDir.getExcludes())));
                } else {
                    fileFilter = FileFilterUtils.fileFileFilter();
                }/*ww  w .j av a 2s  . c  o  m*/

                Collection<File> pathFiles = FileUtils.listFiles(manifestEntryFile, fileFilter,
                        FileFilterUtils.trueFileFilter());

                for (File pathFile : pathFiles) {
                    logger.trace("adding library to classpath: " + pathFile.getAbsolutePath());
                    urls.add(pathFile.toURI().toURL());
                }
            } else {
                logger.trace("adding library to classpath: " + manifestEntryFile.getAbsolutePath());
                urls.add(manifestEntryFile.toURI().toURL());
            }
        } else {
            logger.warn("manifest path not found: " + manifestEntryFile.getAbsolutePath());
        }
    }
}

From source file:adalid.util.i18n.Mapper.java

private boolean map() {
    File rootFolder = PropertiesHandler.getRootFolder();
    if (FilUtils.isNotVisibleDirectory(rootFolder)) {
        return false;
    }/*from  w  w  w.  j  a v a  2  s  . com*/
    String projectSource = rootFolder.getPath() + FILE_SEPARATOR + _project + FILE_SEPARATOR + "source";
    File projectSourceFile = new File(projectSource);
    if (FilUtils.isNotVisibleDirectory(projectSourceFile)) {
        return false;
    }
    RegexFileFilter fileFilter = new RegexFileFilter("^Bundle.*\\.properties$");
    RegexFileFilter dirFilter1 = new RegexFileFilter("build");
    RegexFileFilter dirFilter2 = new RegexFileFilter("velocity");
    IOFileFilter notFileFilter = FileFilterUtils.notFileFilter(FileFilterUtils.or(dirFilter1, dirFilter2));
    Collection<File> bundles = FileUtils.listFiles(projectSourceFile, fileFilter, notFileFilter);
    String base;
    List<File> list;
    for (File bundle : bundles) {
        base = base(bundle);
        if (_map.containsKey(base)) {
            list = _map.get(base);
        } else {
            list = new ArrayList<>();
            _map.put(base, list);
        }
        list.add(bundle);
    }
    return true;
}

From source file:com.ning.metrics.collector.hadoop.processing.LocalSpoolManager.java

public static Collection<File> findFilesInSpoolDirectory(final File spoolDirectory) {
    if (!spoolDirectory.isDirectory()) {
        log.warn("Asked to find files in spool directory but [" + spoolDirectory + "] is not a directory!");
        return Collections.emptyList();
    }//from  ww  w. j ava2 s  .c om
    return FileUtils.listFiles(spoolDirectory, FileFilterUtils.trueFileFilter(),
            FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter("_tmp")));
}

From source file:com.xebialabs.deployit.cli.ext.mustachify.io.Files2.java

/**
 * A variation on {@link FileUtils#listFiles(File, IOFileFilter, IOFileFilter) listFiles}
 * that also optionally includes directories matched in the result.
 *///  w  w w. j a v a  2 s .  co m
public static Collection<File> listFiles(File directory, IOFileFilter fileFilter, IOFileFilter dirFilter,
        boolean includeDirs) {
    if (!directory.isDirectory()) {
        throw new IllegalArgumentException("Parameter 'directory' is not a directory");
    }
    if (fileFilter == null) {
        throw new NullPointerException("Parameter 'fileFilter' is null");
    }

    //Setup effective file filter
    IOFileFilter effFileFilter = FileFilterUtils.andFileFilter(fileFilter,
            FileFilterUtils.notFileFilter(DirectoryFileFilter.INSTANCE));

    //Setup effective directory filter
    IOFileFilter effDirFilter;
    if (dirFilter == null) {
        effDirFilter = FalseFileFilter.INSTANCE;
    } else {
        effDirFilter = FileFilterUtils.andFileFilter(dirFilter, DirectoryFileFilter.INSTANCE);
    }

    //Find files
    Collection<File> files = new LinkedList<File>();
    innerListFiles(files, directory, FileFilterUtils.orFileFilter(effFileFilter, effDirFilter), includeDirs);
    return files;
}

From source file:ext.deployit.community.cli.plainarchive.io.Files2.java

/**
 * A variation on {@link FileUtils#listFiles(File, IOFileFilter, IOFileFilter) listFiles}
 * that also optionally includes directories matched in the result.
 *//*from  www  .j a  va2s . co m*/
public static Collection<File> listFiles(File directory, IOFileFilter fileFilter, IOFileFilter dirFilter,
        boolean includeDirs) {
    if (!directory.isDirectory()) {
        throw new IllegalArgumentException(format("Parameter '%s' is not a directory", directory));
    }
    if (fileFilter == null) {
        throw new NullPointerException("Parameter 'fileFilter' is null");
    }

    //Setup effective file filter
    IOFileFilter effFileFilter = FileFilterUtils.andFileFilter(fileFilter,
            FileFilterUtils.notFileFilter(DirectoryFileFilter.INSTANCE));

    //Setup effective directory filter
    IOFileFilter effDirFilter;
    if (dirFilter == null) {
        effDirFilter = FalseFileFilter.INSTANCE;
    } else {
        effDirFilter = FileFilterUtils.andFileFilter(dirFilter, DirectoryFileFilter.INSTANCE);
    }

    //Find files
    Collection<File> files = new LinkedList<File>();
    innerListFiles(files, directory, FileFilterUtils.orFileFilter(effFileFilter, effDirFilter), includeDirs);
    return files;
}

From source file:com.aionengine.gameserver.dataholders.DataLoader.java

/**
 * This method is supposed to be called from subclass to initialize data loading process.<br>
 * <br>/*from   w  ww.  j  a  v  a2 s.co m*/
 * This method is using file given in the constructor to load the data and there are two possibilities:
 * <ul>
 * <li>Given file is file is in deed the <b>file</b> then it's forwarded to {@link #loadFile(File)} method</li>
 * <li>Given file is a <b>directory</b>, then this method is obtaining list of all visible .txt files in this
 * directory and subdirectiores ( except hidden ones and those named "new" ) and call {@link #loadFile(File)} for
 * each of these files.
 * </ul>
 */
protected void loadData() {
    if (dataFile.isDirectory()) {
        Collection<?> files = FileUtils
                .listFiles(dataFile,
                        FileFilterUtils
                                .andFileFilter(
                                        FileFilterUtils.andFileFilter(
                                                FileFilterUtils
                                                        .notFileFilter(FileFilterUtils.nameFileFilter("new")),
                                                FileFilterUtils.suffixFileFilter(".txt")),
                                        HiddenFileFilter.VISIBLE),
                        HiddenFileFilter.VISIBLE);

        for (Object file1 : files) {
            File f = (File) file1;
            loadFile(f);
        }
    } else {
        loadFile(dataFile);
    }
}

From source file:com.aionemu.gameserver.dataholders.DataLoader.java

/**
 * This method is supposed to be called from subclass to initialize data
 * loading process.<br>//w  ww.jav  a2 s  . c o  m
 * <br>
 * This method is using file given in the constructor to load the data and
 * there are two possibilities:
 * <ul>
 * <li>Given file is file is in deed the <b>file</b> then it's forwarded to
 * {@link #loadFile(File)} method</li>
 * <li>Given file is a <b>directory</b>, then this method is obtaining list
 * of all visible .txt files in this directory and subdirectiores ( except
 * hidden ones and those named "new" ) and call {@link #loadFile(File)} for
 * each of these files.
 * </ul>
 */
@SuppressWarnings("deprecation")
protected void loadData() {
    if (dataFile.isDirectory()) {
        Collection<?> files = FileUtils
                .listFiles(dataFile,
                        FileFilterUtils
                                .andFileFilter(
                                        FileFilterUtils.andFileFilter(
                                                FileFilterUtils
                                                        .notFileFilter(FileFilterUtils.nameFileFilter("new")),
                                                FileFilterUtils.suffixFileFilter(".txt")),
                                        HiddenFileFilter.VISIBLE),
                        HiddenFileFilter.VISIBLE);

        for (Object file1 : files) {
            File f = (File) file1;
            loadFile(f);
        }
    } else {
        loadFile(dataFile);
    }
}

From source file:com.tactfactory.harmony.Harmony.java

/**
 * @param pluginBaseDirectory The plugin base directory
 *///from w ww. j a v a2  s  .c  o  m
private void loadPluginsAndTemplate(final File pluginBaseDirectory) {
    // Cache
    final JSPFProperties props = new JSPFProperties();
    /*props.setProperty(PluginManager.class, "cache.enabled", "true");
            
    // Optional
    props.setProperty(PluginManager.class, "cache.mode",    "weak");
    props.setProperty(PluginManager.class, "cache.file",    "jspf.cache");*/

    // Filters
    final IOFileFilter includeFilter = FileFilterUtils.suffixFileFilter(".jar");

    final IOFileFilter excludeFilter = FileFilterUtils.and(
            FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter("lib")),
            FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter("libs")));

    // Check list of Bundles .jar
    final Collection<File> plugins = TactFileUtils.listFiles(pluginBaseDirectory, includeFilter, excludeFilter);

    // Add Bundles to Plugin Manager &  foldertemplate
    for (File plugin : plugins) {
        this.loadPlugin(plugin, props);
        this.loadTemplates(plugin);
    }
}

From source file:com.nuvolect.deepdive.util.OmniFileFilter.java

/**
 * Returns a filter that accepts files in addition to the {@link OmniFile} objects accepted by the given filter.
 *
 * @param fileFilter a base filter to add to
 * @return a filter that accepts files/*w w  w  .  ja v  a 2  s  . c om*/
 */
private static IOFileFilter setUpEffectiveFileFilter(final IOFileFilter fileFilter) {
    return FileFilterUtils.and(fileFilter, FileFilterUtils.notFileFilter(DirectoryFileFilter.INSTANCE));
}