Java 类org.apache.commons.io.filefilter.NotFileFilter 实例源码

项目:classpath-utils    文件:ClassPathUtils.java   
/**
 * Scan a directory for packages that match. This method is used prior to
 * finding a matching directory. Once the package names is matched
 * handleDir() is used.
 * 
 * @param classes
 *            The classes that have been found.
 * @param packageName
 *            The package name for classes to find.
 * @param dir
 *            The directory to scan.
 * @param cFilter
 *            The class acceptance filter.
 */
private static void scanDir(Set<String> classes, String packageName, File dir, ClassPathFilter cFilter) {
    if (!dir.exists()) {
        return;
    }
    if (dir.isDirectory()) {
        if (dir.getPath().endsWith(packageName.replace('.', '/'))) {
            // we have a match
            handleDir(classes, packageName, dir, cFilter);
        } else {
            // no match check next level
            for (File file : dir.listFiles((FileFilter) new AndFileFilter(DirectoryFileFilter.DIRECTORY,
                    new NotFileFilter(new PrefixFileFilter("."))))) {
                scanDir(classes, packageName, file, cFilter);
            }
        }
    }
    // if it is not a directory we don't process it here as we are looking
    // for directories that start with the packageName.
}
项目:artifactory    文件:DbRepoExportHandler.java   
private void cleanupIncrementalBackupDirectory(FolderInfo sourceFolder, List<ItemInfo> currentFolderChildren,
        File targetDir) {

    //Metadata File filter
    IOFileFilter metadataFilter = new MetadataFileFilter();

    //List all artifacts
    Collection<File> artifacts = Sets.newHashSet(
            targetDir.listFiles((FileFilter) new NotFileFilter(metadataFilter)));
    cleanArtifacts(currentFolderChildren, artifacts);

    //List all sub-target metadata
    Collection<File> subTargetMetadataFiles = FileUtils.listFiles(targetDir, metadataFilter,
            DirectoryFileFilter.INSTANCE);
    cleanMetadata(currentFolderChildren, subTargetMetadataFiles);

    //List all target metadata
    File targetDirMetadataContainerFolder = getMetadataContainerFolder(targetDir);
    Collection<File> targetMetadataFiles = FileUtils.listFiles(targetDirMetadataContainerFolder, metadataFilter,
            DirectoryFileFilter.INSTANCE);
    cleanTargetMetadata(sourceFolder, targetMetadataFiles);
}
项目:FSDevTools    文件:AbstractIntegrationTest.java   
protected File getFirstSpiritFileSyncFolder(final File directory) throws FileNotFoundException {
    checkIsDirectory(directory);
    final Collection<File> directories =
        FileUtils.listFilesAndDirs(testFolder.getRoot(), new NotFileFilter(TrueFileFilter.INSTANCE), DirectoryFileFilter.DIRECTORY);
    for (final File candidate : directories) {
        if (candidate.getName().equals(".FirstSpirit")) {
            return candidate;
        }
    }
    throw new FileNotFoundException("Cannot find .FirstSpirit folder in directory " + directory.getAbsolutePath());
}
项目:FSDevTools    文件:AbstractIntegrationTest.java   
protected boolean containsSubDirectory(final File directory, final String subDirectoryName) {
    checkIsDirectory(directory);
    final Collection<File> directories =
        FileUtils.listFilesAndDirs(testFolder.getRoot(), new NotFileFilter(TrueFileFilter.INSTANCE), DirectoryFileFilter.DIRECTORY);
    for (final File candidate : directories) {
        if (candidate.getName().equals(subDirectoryName)) {
            return true;
        }
    }
    return false;
}
项目:tibco-codereview    文件:BWProjectBuilder.java   
private void addSources(ProjectDefinition project) {
    final File basedir = project.getBaseDir();

    logger.debug(basedir.getAbsolutePath());

    // TODO: ignore child modules folders more properly
    IOFileFilter custom = new IOFileFilter() {
        @Override
        public boolean accept(File file) {
            return file.isDirectory()
                    && !(new File(file, "pom.xml").exists())
                    || file.getAbsolutePath().equals(
                            basedir.getAbsolutePath());
        }

        @Override
        public boolean accept(File dir, String name) {
            return false;
        }
    };

    Collection<File> files = FileUtils.listFiles(basedir,
            new SuffixFileFilter(".process"), new AndFileFilter(
                    new NotFileFilter(new PrefixFileFilter("target")),
                    custom));

    project.addSources(files.toArray(new File[0]));
}
项目:artifactory    文件:ArtifactoryApplicationContext.java   
private void exportEtcDirectory(ExportSettings settings) {
    try {
        File targetBackupDir = new File(settings.getBaseDir(), "etc");
        // TODO: [by fsi] Find a way to copy with permissions kept
        FileUtils.copyDirectory(artifactoryHome.getEtcDir(), targetBackupDir,
                new NotFileFilter(new NameFileFilter("artifactory.lic")), true);
        checkSecurityFolder(targetBackupDir);
    } catch (IOException e) {
        settings.getStatusHolder().error(
                "Failed to export etc directory: " + artifactoryHome.getEtcDir().getAbsolutePath(), e, log);
    }
}
项目:artifactory    文件:ArtifactoryApplicationContext.java   
private void exportHaEtcDirectory(ExportSettings settings) {
    if (artifactoryHome.isHaConfigured()) {
        try {
            File targetBackupDir = new File(settings.getBaseDir(), "ha-etc");
            // TODO: [by fsi] Find a way to copy with permissions kept
            FileUtils.copyDirectory(artifactoryHome.getHaAwareEtcDir(), targetBackupDir,
                    new NotFileFilter(new NameFileFilter("artifactory.lic")));
            checkSecurityFolder(targetBackupDir);
        } catch (IOException e) {
            settings.getStatusHolder().error(
                    "Failed to export etc directory: " + artifactoryHome.getEtcDir().getAbsolutePath(), e, log);
        }
    }
}
项目:artifactory    文件:DbRepoExportHandler.java   
/**
 * Locates the artifacts that were removed from the repo since last backup, but still remain in the backup folder
 * and clean them out.
 *
 * @param currentVfsFolderItems List of vfs items in the current vfs folder
 * @param artifacts             List of artifact files in the current target folder
 */
private void cleanArtifacts(List<ItemInfo> currentVfsFolderItems, Collection<File> artifacts) {
    for (File artifact : artifacts) {
        if (artifact != null) {
            String ileName = artifact.getName();
            ItemInfo itemInfo = getItemByName(currentVfsFolderItems, ileName);
            if (itemInfo == null) {
                if (artifact.isDirectory()) {
                    // If a directory does not exist in data store - we need to recursively handle all of his children as well
                    Collection<File> childArtifacts = Sets.newHashSet(
                            artifact.listFiles((FileFilter) new NotFileFilter(new MetadataFileFilter())));
                    cleanArtifacts(Collections.<ItemInfo>emptyList(), childArtifacts);
                }
                log.debug("Deleting {} from the incremental backup dir since it was " +
                        "deleted from the repository", artifact.getAbsolutePath());
                boolean deleted = FileUtils.deleteQuietly(artifact);
                if (!deleted) {
                    log.warn("Failed to delete {}", artifact.getAbsolutePath());
                }
                // now delete the metadata folder of the file/folder is it exists
                File metadataFolder = getMetadataContainerFolder(artifact);
                if (metadataFolder.exists()) {
                    deleted = FileUtils.deleteQuietly(metadataFolder);
                    if (!deleted) {
                        log.warn("Failed to delete metadata folder {}", metadataFolder.getAbsolutePath());
                    }
                }
            }
        }
    }
}
项目:imcms    文件:FileAdmin.java   
private String createDirectoryOptionList(File[] rootlist, File directory) throws IOException {
    StringBuffer optionlist = new StringBuffer();
    File webappPath = Imcms.getPath();
    for (int i = 0; i < rootlist.length; i++) {
        String dirname = getPathRelativeTo(webappPath, rootlist[i]);
        optionlist.append(getDirectoryOption(File.separator + dirname + File.separator, File.separator + dirname + File.separator));
    }
    File parent = directory.getCanonicalFile().getParentFile();
    if (isUnderRoot(parent, rootlist)) {
        optionlist.append(getDirectoryOption(".." + File.separator, ".." + File.separator));
    }
    File[] dirlist = directory.listFiles((FileFilter) DirectoryFileFilter.INSTANCE);
    Arrays.sort(dirlist, getFileComparator());
    for (int i = 0; null != dirlist && i < dirlist.length; i++) {
        optionlist.append(getDirectoryOption(dirlist[i].getName() + File.separator, dirlist[i].getName() + File.separator));
    }
    File[] filelist = directory.listFiles((FileFilter) new NotFileFilter(DirectoryFileFilter.INSTANCE));
    Arrays.sort(filelist, getFileComparator());

    for (int i = 0; null != filelist && i < filelist.length; i++) {
        String formatedFileSize = HumanReadable.getHumanReadableByteSize(filelist[i].length());
        String filename = filelist[i].getName();
        String fileNameAndSize = filename + " [" + formatedFileSize + "]";
        optionlist.append("<option value=\"");
        optionlist.append(StringEscapeUtils.escapeHtml4(filename));
        optionlist.append("\">");
        optionlist.append(StringEscapeUtils.escapeHtml4(fileNameAndSize));
        optionlist.append("</option>");
    }
    return optionlist.toString();
}
项目:maven-repository-tools    文件:MavenRepositoryDeployer.java   
public static Collection<File> getPomFiles( File repoPath )
{
    Collection<File> pomFiles = new ArrayList<File>();
    Collection<File> leafDirectories = getLeafDirectories( repoPath );
    for ( File leafDirectory : leafDirectories )
    {
        IOFileFilter fileFilter = new AndFileFilter( new WildcardFileFilter( "*.pom" ),
                                           new NotFileFilter( new SuffixFileFilter( "sha1" ) ) );
        pomFiles.addAll( FileUtils.listFiles( leafDirectory, fileFilter, null ) );
    }
    return pomFiles;
}
项目:repositoryminer    文件:RMFileUtils.java   
/**
 * Retrieves all the sub directories from a root directory.
 * 
 * @param path
 *            the root path.
 * @return the sub directories.
 */
public static List<String> getAllDirsAsString(String path) {
    List<File> dirs = (List<File>) FileUtils.listFilesAndDirs(new File(path), new NotFileFilter(TrueFileFilter.INSTANCE),
            DirectoryFileFilter.DIRECTORY);
    List<String> dirsNames = new ArrayList<>();

    for (File f : dirs) {
        dirsNames.add(f.getAbsolutePath());
    }
    return dirsNames;
}
项目:socomo-maven-plugin    文件:EnforceMojo.java   
private Collection<File> getClassFiles() {
    if (classesDirectory.isDirectory()) { 
           IOFileFilter fileFilter = new SuffixFileFilter(".class");
           IOFileFilter dirFilter = new NotFileFilter(new WildcardFileFilter("*-INF")); // META-INF, APP-INF, etc.
        return FileUtils.listFiles(classesDirectory, fileFilter, dirFilter);
       } else {
           return Collections.EMPTY_LIST;
       }
}
项目:jcabi-maven-plugin    文件:VersionalizeMojo.java   
/**
 * Versionalize packages from source to dest.
 * @param src Source directory
 * @param dest Destination
 * @throws IOException If some IO problem
 */
private void versionalize(@NotNull final File src, @NotNull final File dest)
    throws IOException {
    final Collection<File> dirs = FileUtils.listFilesAndDirs(
        src,
        new NotFileFilter(TrueFileFilter.INSTANCE),
        DirectoryFileFilter.DIRECTORY
    );
    final String name = String.format(
        "%s-%s-%s.txt",
        VersionalizeMojo.cleanup(this.project.getGroupId()),
        VersionalizeMojo.cleanup(this.project.getArtifactId()),
        VersionalizeMojo.cleanup(this.project.getPackaging())
    );
    for (final File dir : dirs) {
        if (VersionalizeMojo.files(dir, "*.java").isEmpty()) {
            continue;
        }
        final File ddir = new File(
            dest,
            StringUtils.substring(
                dir.getCanonicalPath(),
                src.getCanonicalPath().length() + 1
            )
        );
        final File version = new File(ddir, name);
        if (version.getParentFile().mkdirs()) {
            Logger.info(this, "created dir %s", version.getParentFile());
        }
        FileUtils.write(version, this.text(ddir));
        Logger.info(this, "File %s added", version);
    }
}
项目:aem-vltsync    文件:InitialRegistrationImpl.java   
private File[] getLocalDirContents() {
    FileFilter fileFilter = new NotFileFilter(new RegexFileFilter("^.vlt-sync.+$"));
    File[] localDirContents = this.localDir.listFiles(fileFilter);

    return localDirContents;
}
项目:deflector    文件:DeflectorIO.java   
public static IOFileFilter notFileFilter( IOFileFilter filter )
{
    return new NotFileFilter( filter );
}
项目:hsac-fitnesse-fixtures    文件:HsacFitNesseRunner.java   
protected FileFilter getFileSectionCopyFilter(Class<?> suiteClass) {
    List<String> excludes = getFileSectionCopyExcludes(suiteClass);
    List<IOFileFilter> excludeFilters = new ArrayList<>(excludes.size());
    excludes.forEach(x -> excludeFilters.add(new WildcardFileFilter(x)));
    return new NotFileFilter(new OrFileFilter(excludeFilters));
}
项目:threatconnect-java    文件:PackageFileFilter.java   
public FilenameFilter createFilenameFilter()
{
    //create the new filter to exclude these file names
    return new NotFileFilter(new WildcardFileFilter(exclude.toArray(new String[] {})));
}
项目:repositoryminer    文件:RMFileUtils.java   
/**
 * Retrieves all the sub directories from a root directory.
 * 
 * @param path
 *            the root path.
 * @return the sub directories.
 */
public static List<File> getAllDirs(String path) {
    return (List<File>) FileUtils.listFilesAndDirs(new File(path), new NotFileFilter(TrueFileFilter.INSTANCE),
            DirectoryFileFilter.DIRECTORY);
}