List of usage examples for org.apache.commons.io.filefilter OrFileFilter OrFileFilter
public OrFileFilter()
OrFileFilter
. From source file:org.apache.rat.Report.java
public static final void main(String args[]) throws Exception { final ReportConfiguration configuration = new ReportConfiguration(); configuration.setHeaderMatcher(Defaults.createDefaultMatcher()); Options opts = buildOptions();//from w w w . jav a 2s .c o m PosixParser parser = new PosixParser(); CommandLine cl = null; try { cl = parser.parse(opts, args); } catch (ParseException e) { System.err.println("Please use the \"--help\" option to see a list of valid commands and options"); System.exit(1); return; // dummy return (won't be reached) to avoid Eclipse complaint about possible NPE for "cl" } if (cl.hasOption('h')) { printUsage(opts); } args = cl.getArgs(); if (args == null || args.length != 1) { printUsage(opts); } else { Report report = new Report(args[0]); if (cl.hasOption('a') || cl.hasOption('A')) { configuration.setAddingLicenses(true); configuration.setAddingLicensesForced(cl.hasOption('f')); configuration.setCopyrightMessage(cl.getOptionValue("c")); } if (cl.hasOption(EXCLUDE_CLI)) { String[] excludes = cl.getOptionValues(EXCLUDE_CLI); if (excludes != null) { final FilenameFilter filter = new NotFileFilter(new WildcardFileFilter(excludes)); report.setInputFileFilter(filter); } } else if (cl.hasOption(EXCLUDE_FILE_CLI)) { String excludeFileName = cl.getOptionValue(EXCLUDE_FILE_CLI); if (excludeFileName != null) { List<String> excludes = FileUtils.readLines(new File(excludeFileName)); final OrFileFilter orFilter = new OrFileFilter(); for (String exclude : excludes) { orFilter.addFileFilter(new RegexFileFilter(exclude)); } final FilenameFilter filter = new NotFileFilter(orFilter); report.setInputFileFilter(filter); } } if (cl.hasOption('x')) { report.report(System.out, configuration); } else { if (!cl.hasOption(STYLESHEET_CLI)) { report.styleReport(System.out, configuration); } else { String[] style = cl.getOptionValues(STYLESHEET_CLI); if (style.length != 1) { System.err.println("please specify a single stylesheet"); System.exit(1); } try { report(System.out, report.getDirectory(System.out), new FileInputStream(style[0]), configuration); } catch (FileNotFoundException fnfe) { System.err.println("stylesheet " + style[0] + " doesn't exist"); System.exit(1); } } } } }
From source file:org.geoserver.bkprst.BrTask.java
/** * Returns an exclusion filter based on directories to avoid during backup based on parameters * /*from w w w . j a va 2 s . c o m*/ * @param includeData * Should data directory be included ? * @param includeGwc * Should GeoWebCache directory be included ? * @param includeLog * Should logs directory be included ? */ protected IOFileFilter getExcludeFilter(boolean includeData, boolean includeGwc, boolean includeLog) { List<IOFileFilter> filesToExclude = new ArrayList<IOFileFilter>(); if (!includeData) { filesToExclude.add(this.dataFilter); } if (!includeGwc) { filesToExclude.add(this.gwcFilter); } if (!includeLog) { filesToExclude.add(this.logFilter); } OrFileFilter filesToExcludeFilter = new OrFileFilter(); filesToExcludeFilter.setFileFilters(filesToExclude); return FileFilterUtils.notFileFilter(filesToExcludeFilter); }
From source file:org.kuali.kfs.sys.batch.service.impl.FilePurgeServiceImpl.java
/** * Gets a directory walker which will //from w ww . ja v a 2 s . co m * @param customAges the custom ages to purge files for * @return a new FilePurgeDirectoryWalker which will walk directories for us */ protected FilePurgeDirectoryWalker getCustomAgesDirectoryWalker(List<FilePurgeCustomAge> customAges) { OrFileFilter fileFilter = new OrFileFilter(); for (FilePurgeCustomAge customAge : customAges) { fileFilter.addFileFilter(customAge.getFileFilter()); } return new FilePurgeDirectoryWalker(fileFilter); }
From source file:org.owasp.dependencycheck.utils.FileFilterBuilder.java
/** * Builds the filter and returns it.//from w w w. j a va2 s . c om * * @return a filter that is the logical OR of all the conditions provided by the add... methods * @throws IllegalStateException if no add... method has been called with one or more arguments */ public FileFilter build() { if (filenames.isEmpty() && extensions.isEmpty() && fileFilters.isEmpty()) { throw new IllegalStateException( "May only be invoked after at least one add... method has been invoked."); } final OrFileFilter filter = new OrFileFilter(); if (!filenames.isEmpty()) { filter.addFileFilter(new NameFileFilter(new ArrayList<String>(filenames))); } if (!extensions.isEmpty()) { filter.addFileFilter(new SuffixFileFilter(new ArrayList<String>(extensions), IOCase.INSENSITIVE)); } for (IOFileFilter iof : fileFilters) { filter.addFileFilter(iof); } return filter; }