Java Code Examples for org.apache.commons.io.filefilter.FileFilterUtils#asFileFilter()
The following examples show how to use
org.apache.commons.io.filefilter.FileFilterUtils#asFileFilter() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProjectImpl.java From japi with MIT License | 6 votes |
@Override public List<IPackage> getPackages() { String masterProjectActionPath = JapiClient.getConfig().getPrefixPath() + JapiClient.getConfig().getProjectJavaPath() + JapiClient.getConfig().getPostfixPath() + "/" + JapiClient.getConfig().getActionReletivePath(); File actionFold = new File(masterProjectActionPath); if (!actionFold.exists()) { throw new JapiException(masterProjectActionPath + " fold not exists."); } final IOFileFilter dirFilter = FileFilterUtils.asFileFilter(new FileFilter() { @Override public boolean accept(File pathname) { return pathname.isDirectory(); } }); Collection<File> folds = FileUtils.listFilesAndDirs(actionFold, dirFilter, TrueFileFilter.INSTANCE); List<IPackage> packages = new ArrayList<>(folds.size()); for (File fold : folds) { if (!fold.getAbsolutePath().equals(actionFold.getAbsolutePath())) { PackageImpl packageImpl = new PackageImpl(); packageImpl.setPackageFold(fold); packages.add(packageImpl); } } return packages; }
Example 2
Source File: PackageImpl.java From japi with MIT License | 6 votes |
@Override public List<IAction> getActions() { final IOFileFilter dirFilter = FileFilterUtils.asFileFilter(new FileFilter() { @Override public boolean accept(File pathname) { return pathname.getName().endsWith(".java") && !pathname.getName().equals("package-info.java"); } }); Collection<File> actionFiles = FileUtils.listFiles(packageFold, dirFilter, null); List<IAction> actions = new ArrayList<>(); for (File actionFile : actionFiles) { ActionImpl action = new ActionImpl(); action.setActionFile(actionFile); actions.add(action); } return actions; }
Example 3
Source File: SvnWorkspaceProviderImpl.java From proctor with Apache License 2.0 | 6 votes |
@Override public void run() { try { if (!shutdown.get()) { LOGGER.info("Actively cleaning up directories older than " + TimeUnit.MILLISECONDS.toHours(cleanupAgeMillis) + " hours"); final IOFileFilter olderThanFilter = FileFilterUtils.asFileFilter(olderThanFileFilter(cleanupAgeMillis)); final IOFileFilter tempDirFilter = FileFilterUtils.prefixFileFilter(prefix); /* * Delete directories that are: * older than [clean up age millis] * starts with temp-dir-prefix */ final IOFileFilter deleteAfterMillisFilter = FileFilterUtils.makeDirectoryOnly( FileFilterUtils.andFileFilter(olderThanFilter, tempDirFilter) ); deleteUserDirectories(rootDirectory, deleteAfterMillisFilter); } else { LOGGER.info("Currently shutdown, skipping older-than directory cleanup"); } } catch (Exception e) { LOGGER.error("Unhandled Exception during directory cleanup", e); } }
Example 4
Source File: PrintPreviewDialog.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected Object[] doInBackground() { IOFileFilter pdfFilter = FileFilterUtils.asFileFilter(this); IOFileFilter suffixFilter = FileFilterUtils.notFileFilter(new SuffixFileFilter(".fo")); IOFileFilter sheetFilter = FileFilterUtils.prefixFileFilter(Constants.CHARACTER_TEMPLATE_PREFIX); IOFileFilter fileFilter = FileFilterUtils.and(pdfFilter, suffixFilter, sheetFilter); IOFileFilter dirFilter = TrueFileFilter.INSTANCE; File dir = new File(ConfigurationSettings.getOutputSheetsDir()); Collection<File> files = FileUtils.listFiles(dir, fileFilter, dirFilter); URI osPath = new File(ConfigurationSettings.getOutputSheetsDir()).toURI(); return files.stream().map(v -> osPath.relativize(v.toURI())).toArray(); }
Example 5
Source File: PrintPreviewDialog.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected Object[] doInBackground() { IOFileFilter pdfFilter = FileFilterUtils.asFileFilter(this); IOFileFilter suffixFilter = FileFilterUtils.notFileFilter(new SuffixFileFilter(".fo")); IOFileFilter sheetFilter = FileFilterUtils.prefixFileFilter(Constants.CHARACTER_TEMPLATE_PREFIX); IOFileFilter fileFilter = FileFilterUtils.and(pdfFilter, suffixFilter, sheetFilter); IOFileFilter dirFilter = TrueFileFilter.INSTANCE; File dir = new File(ConfigurationSettings.getOutputSheetsDir()); Collection<File> files = FileUtils.listFiles(dir, fileFilter, dirFilter); URI osPath = new File(ConfigurationSettings.getOutputSheetsDir()).toURI(); return files.stream().map(v -> osPath.relativize(v.toURI())).toArray(); }
Example 6
Source File: ExportDialog.java From pcgen with GNU Lesser General Public License v2.1 | 4 votes |
private void refreshFiles() { String outputSheetsDir; SheetFilter sheetFilter = (SheetFilter) exportBox.getSelectedItem(); IOFileFilter ioFilter = FileFilterUtils.asFileFilter(sheetFilter); IOFileFilter prefixFilter; String defaultSheet = null; String outputSheetDirectory = SettingsHandler.getGameAsProperty().get().getOutputSheetDirectory(); if (outputSheetDirectory == null) { outputSheetsDir = ConfigurationSettings.getOutputSheetsDir() + "/" + sheetFilter.getPath(); } else { outputSheetsDir = ConfigurationSettings.getOutputSheetsDir() + "/" + outputSheetDirectory + "/" + sheetFilter.getPath(); } if (partyBox.isSelected()) { prefixFilter = FileFilterUtils.prefixFileFilter(Constants.PARTY_TEMPLATE_PREFIX); } else { CharacterFacade character = (CharacterFacade) characterBox.getSelectedItem(); prefixFilter = FileFilterUtils.prefixFileFilter(Constants.CHARACTER_TEMPLATE_PREFIX); defaultSheet = character.getDefaultOutputSheet(sheetFilter == SheetFilter.PDF); if (StringUtils.isEmpty(defaultSheet)) { defaultSheet = outputSheetsDir + "/" + SettingsHandler.getGameAsProperty().get().getOutputSheetDefault(sheetFilter.getTag()); } } IOFileFilter filter = FileFilterUtils.and(prefixFilter, ioFilter); List<File> files = FileFilterUtils.filterList(filter, allTemplates); Collections.sort(files); URI osPath = new File(outputSheetsDir).toURI(); URI[] uriList = new URI[files.size()]; Arrays.setAll(uriList, i -> osPath.relativize(files.get(i).toURI())); fileList.setListData(uriList); if (StringUtils.isNotEmpty(defaultSheet)) { URI defaultPath = new File(defaultSheet).toURI(); fileList.setSelectedValue(osPath.relativize(defaultPath), true); } }
Example 7
Source File: ExportDialog.java From pcgen with GNU Lesser General Public License v2.1 | 4 votes |
private void refreshFiles() { String outputSheetsDir; SheetFilter sheetFilter = (SheetFilter) exportBox.getSelectedItem(); IOFileFilter ioFilter = FileFilterUtils.asFileFilter(sheetFilter); IOFileFilter prefixFilter; String defaultSheet = null; String outputSheetDirectory = SettingsHandler.getGameAsProperty().get().getOutputSheetDirectory(); if (outputSheetDirectory == null) { outputSheetsDir = ConfigurationSettings.getOutputSheetsDir() + "/" + sheetFilter.getPath(); } else { outputSheetsDir = ConfigurationSettings.getOutputSheetsDir() + "/" + outputSheetDirectory + "/" + sheetFilter.getPath(); } if (partyBox.isSelected()) { prefixFilter = FileFilterUtils.prefixFileFilter(Constants.PARTY_TEMPLATE_PREFIX); } else { CharacterFacade character = (CharacterFacade) characterBox.getSelectedItem(); prefixFilter = FileFilterUtils.prefixFileFilter(Constants.CHARACTER_TEMPLATE_PREFIX); defaultSheet = character.getDefaultOutputSheet(sheetFilter == SheetFilter.PDF); if (StringUtils.isEmpty(defaultSheet)) { defaultSheet = outputSheetsDir + "/" + SettingsHandler.getGameAsProperty().get().getOutputSheetDefault(sheetFilter.getTag()); } } IOFileFilter filter = FileFilterUtils.and(prefixFilter, ioFilter); List<File> files = FileFilterUtils.filterList(filter, allTemplates); Collections.sort(files); URI osPath = new File(outputSheetsDir).toURI(); URI[] uriList = new URI[files.size()]; Arrays.setAll(uriList, i -> osPath.relativize(files.get(i).toURI())); fileList.setListData(uriList); if (StringUtils.isNotEmpty(defaultSheet)) { URI defaultPath = new File(defaultSheet).toURI(); fileList.setSelectedValue(osPath.relativize(defaultPath), true); } }