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

项目:de.lgohlke.selenium-webdriver    文件:ErrorLoggingWebDriverEventListenerIT.java   
@Test
public void shouldLogJSErrors() throws IOException {
    driverChrome.get(httpServer.url("/form.html"));

    try {
        ((JavascriptExecutor) driverChrome).executeScript("NOT_FOUND();");
        fail("should fail");
    } catch (WebDriverException e) {
        // ok
    }

    File[] files = tempFolder.listFiles((FileFilter) new AbstractFileFilter() {
        @Override
        public boolean accept(File file) {
            return file.getName().endsWith(".log");
        }
    });
    assertThat(files.length).isEqualTo(1);
    String contentOfLogFile = FileUtils.readFileToString(files[0], Charset.defaultCharset());
    assertThat(contentOfLogFile).contains("unknown error: NOT_FOUND is not defined");
}
项目:Leo    文件:BaseFileCollectionReader.java   
/**
 * This method is called during initialization, and does nothing by default. Subclasses should override it to perform one-time startup logic.
 */
@Override
public void initialize() throws ResourceInitializationException {
    super.initialize();

    mInDir = new File(inputDirectoryPath);
    if(mInDir == null || !mInDir.exists() || !mInDir.isDirectory())
        throw new ResourceInitializationException("Input Directory does not exist or is not a directory!", null);

    if(StringUtils.isNotBlank(fileNameFilterJSON) && StringUtils.isNotBlank(fileNameFilterName)) {
        try {
            Class<?> filterClass = Class.forName(fileNameFilterName);
            filenameFilter = new Gson().fromJson(fileNameFilterJSON, (Class<? extends AbstractFileFilter>) filterClass);
        } catch (ClassNotFoundException e) {
            throw new ResourceInitializationException(e);
        }
    }

    findFiles(mInDir);
    mFileIndex = 0;
}
项目:redhat-repository-validator    文件:AppConfig.java   
@Bean
public IOFileFilter expectedRootFilesFilter() {
    final String validatedRepositoryAbsolutePath = validatorContext().getValidatedRepository().getAbsolutePath();
    final String[] expectedRootFiles = expectedRootFiles();

    IOFileFilter expectedRootFileFilter = new AbstractFileFilter() {
        @Override
        public boolean accept(File dir, String name) {
            if (dir.getAbsolutePath().equals(validatedRepositoryAbsolutePath) &&
                    ArrayUtils.contains(expectedRootFiles, name.toLowerCase())) {
                return true;
            }
            return false;
        }
    };

    return expectedRootFileFilter;
}
项目:vt-support    文件:StorageImpl.java   
private static String[] tileFilenames(File directory) {
  return directory.list(new AbstractFileFilter() {
    @Override
    public boolean accept(File dir, String name) {
      return name.matches("\\d*");
    }
  });
}
项目:artifactory    文件:TrafficReader.java   
/**
 * Returns a collection of traffic entry log files which are relevant to the given time window
 *
 * @param startDate Time window start date
 * @param endDate   Time window end date
 * @return Collection<File> - Collection of file objects that represent the traffic entry log files which are
 *         relevant to the given time window
 */
public Collection<File> readFiles(Date startDate, Date endDate) {
    IOFileFilter trafficLogFileFilter = new AbstractFileFilter() {
        @Override
        public boolean accept(File file) {
            String logFileName = file.getName();
            return logFileName.contains(LOG_PREFIX) && logFileName.contains(LOG_SUFFIX);
        }
    };
    Collection<File> collection = FileUtils.listFiles(logDir, trafficLogFileFilter, DirectoryFileFilter.DIRECTORY);
    List<File> trafficLogFiles = Lists.newArrayList(collection);
    Collections.sort(trafficLogFiles);
    List<File> selectedFiles = new ArrayList<>();
    for (File logFile : trafficLogFiles) {
        Date[] logFileDates = getLogFileDates(logFile);

        //Sanity check
        if (logFileDates.length != 2) {
            throw new RuntimeException("Could not read log file dates.");
        }

        //Sanity check
        Date logFileStartDate = logFileDates[0];
        Date logFileEndDate = logFileDates[1];
        if ((logFileStartDate == null) || (logFileEndDate == null)) {
            throw new RuntimeException("Log file dates cannot be null.");
        }

        boolean withinRange = isDateWithinRange(logFileStartDate, logFileEndDate, startDate, endDate);
        if (withinRange) {
            selectedFiles.add(logFile);
        }
    }
    return selectedFiles;
}
项目:leroy_jenkins    文件:NewProject.java   
private void readWorkflowsFromDisk(String workflowsDir) {
    File wfDir = new File(workflowsDir);
    workflow = new ArrayList<String>();
    if (wfDir.exists() && wfDir.canRead()) {
        //get file names
        IOFileFilter workflowFileFilter = new AbstractFileFilter() {
            @Override
            public boolean accept(File file) {
                try {
                    if (LeroyUtils.isWorkflow(file)) {
                        return true;
                    }
                } catch (Throwable t) {
                    t.printStackTrace();
                }
                return false;
            }
        };
        Iterator<File> fileIterator = FileUtils.iterateFiles(new File(workflowsDir), workflowFileFilter, TrueFileFilter.INSTANCE);
        if (fileIterator != null) {
            URI workFlowsBase = new File(workflowsDir).toURI();
            while (fileIterator.hasNext()) {
                // get relative path using workflow folder as a base and remove extension
                File wf = fileIterator.next();
                String relative = workFlowsBase.relativize(wf.toURI()).getPath();
                String wfName = relative.substring(0, relative.lastIndexOf('.'));
                workflow.add(wfName);
            }
        }
    }
}
项目:wisdom    文件:RunnerUtils.java   
/**
 * Checks if a file having somewhat the current tested application name is contained in the given directory. This
 * method follows the default maven semantic. The final file is expected to have a name compliant with the
 * following rules: <code>artifactId-version.jar</code>. If the version ends with <code>-SNAPSHOT</code>,
 * it just checks for <code>artifactId-stripped_version</code>, where stripped version is the version without the
 * <code>SNAPSHOT</code> part.
 * <p>
 * The artifactId and version are read from the <code>target/osgi/osgi.properties</code> file,
 * that should have been written by the Wisdom build process.
 *
 * @param directory the directory
 * @return the bundle file if found
 * @throws java.io.IOException if something bad happens.
 */
public static File detectApplicationBundleIfExist(File directory) throws IOException {
    Properties properties = getMavenProperties();
    if (properties == null || directory == null || !directory.isDirectory()) {
        return null;
    }

    final String artifactId = properties.getProperty("project.artifactId");
    final String groupId = properties.getProperty("project.groupId");
    final String bsn = getBundleSymbolicName(groupId, artifactId);
    String version = properties.getProperty("project.version");
    final String strippedVersion;
    if (version.endsWith("-SNAPSHOT")) {
        strippedVersion = version.substring(0, version.length() - "-SNAPSHOT".length());
    } else {
        strippedVersion = version;
    }

    Iterator<File> files = FileUtils.iterateFiles(directory, new AbstractFileFilter() {
        @Override
        public boolean accept(File file) {
            return file.isFile()
                    && file.getName().startsWith(bsn + "-" + strippedVersion)
                    && file.getName().endsWith(".jar");
        }
    }, TrueFileFilter.INSTANCE);

    if (files.hasNext()) {
        return files.next();
    }
    return null;
}
项目:artifactory    文件:BuildServiceImpl.java   
@Override
public void importFrom(ImportSettings settings) {
    final MutableStatusHolder multiStatusHolder = settings.getStatusHolder();
    multiStatusHolder.status("Starting build info import", log);

    dbService.invokeInTransaction("BuildImport-deleteAllBuilds", new Callable<Object>() {
        @Override
        public Object call() throws Exception {
            try {
                // delete all existing builds
                buildStoreService.deleteAllBuilds();
            } catch (Exception e) {
                multiStatusHolder.error("Failed to delete builds root node", e, log);
            }
            return null;
        }
    });

    File buildsFolder = new File(settings.getBaseDir(), BUILDS_EXPORT_DIR);
    String buildsFolderPath = buildsFolder.getPath();
    if (!buildsFolder.exists()) {
        multiStatusHolder.status("'" + buildsFolderPath + "' folder is either non-existent or not a " +
                "directory. Build info import was not performed", log);
        return;
    }

    IOFileFilter buildExportFileFilter = new AbstractFileFilter() {
        @Override
        public boolean accept(File file) {
            String fileName = file.getName();
            return fileName.startsWith("build") && fileName.endsWith(".xml");
        }
    };

    Collection<File> buildExportFiles =
            FileUtils.listFiles(buildsFolder, buildExportFileFilter, DirectoryFileFilter.DIRECTORY);

    if (buildExportFiles.isEmpty()) {
        multiStatusHolder.status("'" + buildsFolderPath + "' folder does not contain build export files. " +
                "Build info import was not performed", log);
        return;
    }

    importBuildFiles(settings, buildExportFiles);
    multiStatusHolder.status("Finished build info import", log);
}
项目:codemining-treelm    文件:AbstractContextFreeGrammar.java   
@Override
public AbstractFileFilter modelledFilesFilter() {
    return tokenizer.getFileFilter();
}
项目:codemining-treelm    文件:TsgLM.java   
@Override
public AbstractFileFilter modelledFilesFilter() {
    return tokenizer.getFileFilter();
}
项目:codemining-sequencelm    文件:AbstractNGramLM.java   
@Override
public AbstractFileFilter modelledFilesFilter() {
    return getTokenizer().getFileFilter();
}
项目:codemining-sequencelm    文件:SimpleCachedNGramLM.java   
@Override
public AbstractFileFilter modelledFilesFilter() {
    return baseNgram.modelledFilesFilter();
}
项目:codemining-sequencelm    文件:IdentifierOnlyCachedNGramLM.java   
@Override
public AbstractFileFilter modelledFilesFilter() {
    return baseNgram.modelledFilesFilter();
}
项目:codemining-sequencelm    文件:HiddenMarkovModelLM.java   
@Override
public AbstractFileFilter modelledFilesFilter() {
    return tokenizer.getFileFilter();
}
项目:tassal    文件:JavaTypeTokenizer.java   
@Override
public AbstractFileFilter getFileFilter() {
    return baseTokenizer.getFileFilter();
}
项目:tassal    文件:JavaTokenTypeTokenizer.java   
@Override
public AbstractFileFilter getFileFilter() {
    return javaCodeFiler;
}
项目:tassal    文件:JavaWhitespaceTokenizer.java   
@Override
public AbstractFileFilter getFileFilter() {
    return javaCodeFilter;
}
项目:tassal    文件:JavaWhitespaceTokenizer.java   
@Override
public AbstractFileFilter getFileFilter() {
    final TokenizerImplementation tok = new TokenizerImplementation();
    return tok.getFileFilter();
}
项目:tassal    文件:JavaASTAnnotatedTokenizer.java   
@Override
public AbstractFileFilter getFileFilter() {
    return baseTokenizer.getFileFilter();
}
项目:tassal    文件:JavaTokenizer.java   
@Override
public AbstractFileFilter getFileFilter() {
    return javaCodeFileFilter;
}
项目:tassal    文件:AbstractJygmentsTokenizer.java   
@Override
public AbstractFileFilter getFileFilter() {
    return codeFilter;
}
项目:tassal    文件:CDTTokenizer.java   
@Override
public AbstractFileFilter getFileFilter() {
    return C_CODE_TOKENIZER;
}
项目:tassal    文件:CppWhitespaceTokenizer.java   
@Override
public AbstractFileFilter getFileFilter() {
    return CPP_CODE_FILTER;
}
项目:tassal    文件:AbstractCdtASTAnnotatedTokenizer.java   
@Override
public AbstractFileFilter getFileFilter() {
    return baseTokenizer.getFileFilter();
}
项目:tassal    文件:CppTokenTypeTokenizer.java   
@Override
public AbstractFileFilter getFileFilter() {
    return CPP_CODE_FILTER;
}
项目:tassal    文件:AbstractPythonTokenizer.java   
@Override
public AbstractFileFilter getFileFilter() {
    return pythonCodeFilter;
}
项目:tassal    文件:JavascriptTokenizer.java   
@Override
public AbstractFileFilter getFileFilter() {
    return JAVASCRIPT_CODE_FILTER;
}
项目:tassal    文件:FormattingTokenizer.java   
@Override
public AbstractFileFilter getFileFilter() {
    return baseTokenizer.getFileFilter();
}
项目:codemining-core    文件:JavaTypeTokenizer.java   
@Override
public AbstractFileFilter getFileFilter() {
    return baseTokenizer.getFileFilter();
}
项目:codemining-core    文件:JavaTokenTypeTokenizer.java   
@Override
public AbstractFileFilter getFileFilter() {
    return javaCodeFiler;
}
项目:codemining-core    文件:JavaWhitespaceTokenizer.java   
@Override
public AbstractFileFilter getFileFilter() {
    return javaCodeFilter;
}
项目:codemining-core    文件:JavaWhitespaceTokenizer.java   
@Override
public AbstractFileFilter getFileFilter() {
    final TokenizerImplementation tok = new TokenizerImplementation();
    return tok.getFileFilter();
}
项目:codemining-core    文件:JavaASTAnnotatedTokenizer.java   
@Override
public AbstractFileFilter getFileFilter() {
    return baseTokenizer.getFileFilter();
}
项目:codemining-core    文件:JavaTokenizer.java   
@Override
public AbstractFileFilter getFileFilter() {
    return javaCodeFileFilter;
}
项目:codemining-core    文件:AbstractJygmentsTokenizer.java   
@Override
public AbstractFileFilter getFileFilter() {
    return codeFilter;
}
项目:codemining-core    文件:CDTTokenizer.java   
@Override
public AbstractFileFilter getFileFilter() {
    return C_CODE_TOKENIZER;
}
项目:codemining-core    文件:CppWhitespaceTokenizer.java   
@Override
public AbstractFileFilter getFileFilter() {
    return CPP_CODE_FILTER;
}
项目:codemining-core    文件:AbstractCdtASTAnnotatedTokenizer.java   
@Override
public AbstractFileFilter getFileFilter() {
    return baseTokenizer.getFileFilter();
}
项目:codemining-core    文件:CppTokenTypeTokenizer.java   
@Override
public AbstractFileFilter getFileFilter() {
    return CPP_CODE_FILTER;
}
项目:codemining-core    文件:AbstractPythonTokenizer.java   
@Override
public AbstractFileFilter getFileFilter() {
    return pythonCodeFilter;
}