Example usage for org.apache.commons.io.filefilter DelegateFileFilter DelegateFileFilter

List of usage examples for org.apache.commons.io.filefilter DelegateFileFilter DelegateFileFilter

Introduction

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

Prototype

public DelegateFileFilter(FileFilter filter) 

Source Link

Document

Constructs a delegate file filter around an existing FileFilter.

Usage

From source file:com.thruzero.common.core.fs.FileAndDirectoryFilter.java

/**
 * @param directoryFilter used to filter directories - if null, then no directories will be processed. Use the
 * apache.commons {@code DirectoryFileFilter} to process all directories.
 * @param fileFilter used to filter files - if null, then no files will be processed. Use the apache.commons
 * {@code TrueFileFilter} to process all files.
 *///from  w  ww .  jav a  2  s.co m
public FileAndDirectoryFilter(final FileFilter directoryFilter, final FileFilter fileFilter) {
    this.directoryFilter = directoryFilter == null ? null : new DelegateFileFilter(directoryFilter);
    this.fileFilter = fileFilter == null ? null : new DelegateFileFilter(fileFilter);
}

From source file:com.thruzero.common.core.fs.FileAndDirectoryFilter.java

/**
 * @param directorynameFilter used to filter directories - if null, then no directories will be processed. Use the
 * apache.commons {@code DirectoryFileFilter} to process all directories.
 * @param filenameFilter used to filter files - if null, then no files will be processed. Use the apache.commons
 * {@code TrueFileFilter} to process all files.
 *//*from w  w  w  .  java  2  s  . c om*/
public FileAndDirectoryFilter(final FilenameFilter directorynameFilter, final FilenameFilter filenameFilter) {
    this.directoryFilter = directorynameFilter == null ? null : new DelegateFileFilter(directorynameFilter);
    this.fileFilter = filenameFilter == null ? null : new DelegateFileFilter(filenameFilter);
}

From source file:org.jvnet.hudson.plugins.backup.utils.BackupTask.java

/**
 * Returns a file filter filtering files/dirs to NOT include from jobs' workspace
 * (this means the returned file filter is already a negation).
 *//*  w  w  w.j  a  va2 s.c o m*/
public static IOFileFilter createJobsExclusionFileFilter(String hudsonWorkDir, String jobIncludes,
        String jobExcludes, boolean caseSensitive) {

    // directory scanning will be done from the HUDSON_HOME/jobs directory
    DirectoryScanner directoryScanner = new DirectoryScanner();
    directoryScanner.setBasedir(new File(hudsonWorkDir, JOBS_NAME));
    directoryScanner.setCaseSensitive(caseSensitive);

    // for each specified inclusion, we need to prefix it with "*/workspace"
    // to match the workspace directory of each job
    if (jobIncludes != null && jobIncludes.length() > 0) {
        // jobIncludes looks like file1,fil2,dir1/**,dir2/*
        // we need to prefix the first element in the list with "*/workspace"
        jobIncludes = jobIncludes.replaceAll(Matcher.quoteReplacement("\\"), "/");
        jobIncludes = "*/" + WORKSPACE_NAME + '/' + jobIncludes;
        // we do the same for all other elements in the list
        jobIncludes = jobIncludes.replaceAll(",", ",*/" + WORKSPACE_NAME + '/');
        directoryScanner.setIncludes(jobIncludes.split(","));
    } else {
        directoryScanner.setIncludes(null);
    }

    // the same is done for exclusions
    if (jobExcludes != null && jobExcludes.length() > 0) {
        jobExcludes = jobExcludes.replaceAll(Matcher.quoteReplacement("\\"), "/");
        jobExcludes = "*/" + WORKSPACE_NAME + '/' + jobExcludes;
        jobExcludes = jobExcludes.replaceAll(",", ",*/" + WORKSPACE_NAME + '/');
        directoryScanner.setExcludes(jobExcludes.split(","));
    } else {
        directoryScanner.setExcludes(null);
    }

    directoryScanner.scan();

    FileFilter ff = new SimpleFileFilter(directoryScanner.getBasedir(),
            directoryScanner.getExcludedDirectories(), directoryScanner.getExcludedFiles());

    return FileFilterUtils.notFileFilter(new DelegateFileFilter(ff));
}