Package org.apache.commons.io.filefilter

Examples of org.apache.commons.io.filefilter.NameFileFilter


        File grandParentDir = new File(getTestDirectory(), "grandparent");
        File parentDir      = new File(grandParentDir, "parent");
        File childDir       = new File(parentDir, "child");
        createFilesForTestCopyDirectory(grandParentDir, parentDir, childDir);

        NameFileFilter filter = new NameFileFilter(new String[] {"parent", "child", "file3.txt"});
        File destDir       = new File(getTestDirectory(), "copydest");

        FileUtils.copyDirectory(grandParentDir, destDir, filter);
        List<File> files  = LIST_WALKER.list(destDir);
        assertEquals(3, files.size());
View Full Code Here


    private static IOFileFilter createNameFilter(File[] files) {
        String[] names = new String[files.length];
        for (int i = 0; i < files.length; i++) {
            names[i] = files[i].getName();
        }
        return new NameFileFilter(names);
    }
View Full Code Here

        monitors = new ArrayList<FileAlterationMonitor>();

        { // content monitor
            final FileAlterationObserver observer;
            if (sourceDocumentName != null) {
                observer = new FileAlterationObserver(sourceDirectory, new NameFileFilter(sourceDocumentName));
            } else if (sourceDirectory != null) {
                observer = new FileAlterationObserver(sourceDirectory, new RegexFileFilter(ASCIIDOC_REG_EXP_EXTENSION));
            } else {
                monitors = null; // no need to start anything because there is no content
                return;
            }

            final FileAlterationMonitor monitor = new FileAlterationMonitor(interval);
            final FileAlterationListener listener = new FileAlterationListenerAdaptor() {
                @Override
                public void onFileCreate(final File file) {
                    getLog().info("File " + file.getAbsolutePath() + " created.");
                    needsUpdate.set(true);
                }

                @Override
                public void onFileChange(final File file) {
                    getLog().info("File " + file.getAbsolutePath() + " updated.");
                    needsUpdate.set(true);
                }

                @Override
                public void onFileDelete(final File file) {
                    getLog().info("File " + file.getAbsolutePath() + " deleted.");
                    needsUpdate.set(true);
                }
            };

            observer.addListener(listener);
            monitor.addObserver(observer);

            monitors.add(monitor);
        }

        { // resources monitors
            if (synchronizations != null) {
                for (final Synchronization s : synchronizations) {
                    final FileAlterationMonitor monitor = new FileAlterationMonitor(interval);
                    final FileAlterationListener listener = new FileAlterationListenerAdaptor() {
                        @Override
                        public void onFileCreate(final File file) {
                            getLog().info("File " + file.getAbsolutePath() + " created.");
                            synchronize(s);
                            needsUpdate.set(true);
                        }

                        @Override
                        public void onFileChange(final File file) {
                            getLog().info("File " + file.getAbsolutePath() + " updated.");
                            synchronize(s);
                            needsUpdate.set(true);
                        }

                        @Override
                        public void onFileDelete(final File file) {
                            getLog().info("File " + file.getAbsolutePath() + " deleted.");
                            FileUtils.deleteQuietly(file);
                            needsUpdate.set(true);
                        }
                    };

                    final File source = s.getSource();

                    final FileAlterationObserver observer;
                    if (source.isDirectory()) {
                        observer = new FileAlterationObserver(source);
                    } else {
                        observer = new FileAlterationObserver(source.getParentFile(), new NameFileFilter(source.getName()));
                    }

                    observer.addListener(listener);
                    monitor.addObserver(observer);
View Full Code Here

    private static IOFileFilter createNameFilter(File[] files) {
        String[] names = new String[files.length];
        for (int i = 0; i < files.length; i++) {
            names[i] = files[i].getName();
        }
        return new NameFileFilter(names);
    }
View Full Code Here

        File grandParentDir = new File(getTestDirectory(), "grandparent");
        File parentDir      = new File(grandParentDir, "parent");
        File childDir       = new File(parentDir, "child");
        createFilesForTestCopyDirectory(grandParentDir, parentDir, childDir);

        NameFileFilter filter = new NameFileFilter(new String[] {"parent", "child", "file3.txt"});
        File destDir       = new File(getTestDirectory(), "copydest");

        FileUtils.copyDirectory(grandParentDir, destDir, filter);
        List<File> files  = LIST_WALKER.list(destDir);
        assertEquals(3, files.size());
View Full Code Here

    private static IOFileFilter createNameFilter(File[] files) {
        String[] names = new String[files.length];
        for (int i = 0; i < files.length; i++) {
            names[i] = files[i].getName();
        }
        return new NameFileFilter(names);
    }
View Full Code Here

   
    public static IOFileFilter decorateWithDisabledList(IOFileFilter filter) throws IOException {
        String disabled = System.getProperty("fop.layoutengine.disabled");
        if (disabled != null && disabled.length() > 0) {
            filter = new AndFileFilter(new NotFileFilter(
                           new NameFileFilter(readDisabledTestcases(new File(disabled)))),
                    filter);
        }
        return filter;
    }
View Full Code Here

        File mainDir = new File("test/layoutengine");
        IOFileFilter filter;
        String single = System.getProperty("fop.layoutengine.single");
        String startsWith = System.getProperty("fop.layoutengine.starts-with");
        if (single != null) {
            filter = new NameFileFilter(single);
        } else if (startsWith != null) {
            filter = new PrefixFileFilter(startsWith);
            filter = new AndFileFilter(filter, new SuffixFileFilter(".xml"));
        } else {
            filter = new SuffixFileFilter(".xml");
View Full Code Here

       
        IOFileFilter filter;
        String single = System.getProperty("fop.fotree.single");
        String startsWith = System.getProperty("fop.fotree.starts-with");
        if (single != null) {
            filter = new NameFileFilter(single);
        } else if (startsWith != null) {
            filter = new PrefixFileFilter(startsWith);
            filter = new AndFileFilter(filter, new SuffixFileFilter(".fo"));
        } else {
            filter = new SuffixFileFilter(".fo");
View Full Code Here

    boolean resourceCopyFailed = false;

    // Dependencies (CSS, images, javascripts)
    File includes = new File(this.templateDir, "html/includes/");

    FileUtilities.copyDirectoryToDirectory(includes, directory, new NotFileFilter(new NameFileFilter(
        new String[] { "CVS", ".svn" })));

    Map<String, Integer> indexes = new TreeMap<String, Integer>(String.CASE_INSENSITIVE_ORDER);
   
    for (Chapter c : b.getChapters()) {
View Full Code Here

TOP

Related Classes of org.apache.commons.io.filefilter.NameFileFilter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.