List of usage examples for org.apache.commons.io.filefilter SuffixFileFilter SuffixFileFilter
public SuffixFileFilter(List suffixes)
From source file:com.googlecode.l10nmavenplugin.validators.property.SpellCheckValidator.java
/** * Initialize by loading dictionaries following {@link Locale} naming convention * /* www . j a va 2 s .c o m*/ * @param logger * @param directory * dictionaries location */ public SpellCheckValidator(L10nValidatorLogger logger, File directory) { super(logger); spellCheckerLocaleRepository = new LocaleTreeSpellCheckerRepository(logger); if (directory != null) { logger.getLogger().info("Looking for .dic files in: " + directory.getAbsolutePath()); File[] files = directory.listFiles((FilenameFilter) new SuffixFileFilter(".dic")); if (files == null || files.length == 0) { logger.getLogger().warn("No dictionary file under folder " + directory.getAbsolutePath() + ". Skipping spellcheck validation."); } else { // Load each dictionary, using file name to detect associated locale for (File file : files) { try { String fileName = FilenameUtils.getBaseName(file.getName()); String localePart = null; String[] parts = fileName.split("_", 2); if (parts[0].length() == 2) { localePart = fileName; } else if (parts.length == 2) { localePart = parts[1]; } Locale locale = PropertiesFileUtils.getLocale(localePart); logger.getLogger().info( "Loading file <" + file.getName() + "> associated to locale <" + locale + ">"); SpellDictionary dictionary = new SpellDictionaryHashMap(file); spellCheckerLocaleRepository.addDictionary(locale, dictionary); } catch (IOException e) { logger.getLogger().error(e); } } } } else { logger.getLogger().warn("No dictionary folder provided, skipping spellcheck validation."); } }
From source file:com.funambol.server.cleanup.ClientLogCleanUpAgentTest.java
@Override protected void setUp() throws Exception { super.setUp(); agent = new ClientLogCleanUpAgent(clientsLogDir, targetArchivationDirectory, activationThreshold, maxNumberOfArchivedFiles, numberOfArchivedFilesToDelete, timeToRest, lockName); try {//w w w .j a v a 2 s. co m FileUtils.forceMkdir(new File(TARGET_DIR)); FileUtils.cleanDirectory(new File(TARGET_DIR)); FileUtils.copyDirectory(new File(BASE_DIR), new File(TARGET_DIR), new NotFileFilter(new SuffixFileFilter(".svn"))); } catch (IOException e) { assertTrue("Unable to handle target dir", true); } }
From source file:com.googlecode.l10nmavenplugin.validators.orchestrator.DirectoryValidator.java
/** * Load a group of Properties file from a directory *//*from w ww .j av a2 s . co m*/ protected int loadPropertiesFamily(File directory, List<L10nReportItem> reportItems, List<PropertiesFamily> propertiesFamilies) { int nbErrors = 0; logger.getLogger().info("Looking for .properties files in: " + directory.getAbsolutePath()); List<PropertiesFile> propertiesFilesInDir = new ArrayList<PropertiesFile>(); File[] files = directory.listFiles((FilenameFilter) new SuffixFileFilter(".properties")); if (files == null || files.length == 0) { logger.getLogger().warn("No properties file under folder " + directory.getAbsolutePath() + ". Skipping l10n validation."); } else { for (File file : files) { // Validate File nbErrors += duplicateKeysValidator.validate(file, reportItems); // Load it normally propertiesFilesInDir.add(loadPropertiesFile(file, reportItems)); } } propertiesFamilies.addAll(loadPropertiesFamily(propertiesFilesInDir)); return nbErrors; }
From source file:ar.com.fluxit.jqa.JQAMavenPlugin.java
private void doExecute(File buildDirectory, File outputDirectory, File testOutputDirectory, MavenProject project, File sourceDir, String sourceJavaVersion) throws IntrospectionException, TypeFormatException, FileNotFoundException, IOException, RulesContextFactoryException, ExporterException { // Add project dependencies to classpath getLog().debug("Adding project dependencies to classpath"); final Collection<File> classPath = new ArrayList<File>(); @SuppressWarnings("unchecked") final Set<Artifact> artifacts = project.getArtifacts(); for (final Artifact artifact : artifacts) { classPath.add(artifact.getFile()); }/*from w w w. jav a 2 s . co m*/ // Add project classes to classpath if (outputDirectory != null) { classPath.add(outputDirectory); } if (testOutputDirectory != null) { classPath.add(testOutputDirectory); } getLog().debug("Adding project classes to classpath"); final Collection<File> classFiles = FileUtils.listFiles(buildDirectory, new SuffixFileFilter(RulesContextChecker.CLASS_SUFFIX), TrueFileFilter.INSTANCE); // Reads the config file getLog().debug("Reading rules context"); final RulesContext rulesContext = RulesContextFactoryLocator.getRulesContextFactory() .getRulesContext(getRulesContextFile().getPath()); getLog().debug("Checking rules for " + classFiles.size() + " files"); final CheckingResult checkingResult = RulesContextChecker.INSTANCE.check(project.getArtifactId(), classFiles, classPath, rulesContext, new File[] { sourceDir }, sourceJavaVersion, getLogger()); CheckingResultExporter.INSTANCE.export(checkingResult, project.getArtifactId(), getResultsDirectory(), this.xslt, getLogger()); }
From source file:algorithm.OpenStegoRandomLSBSteganography.java
@Override SuffixFileFilter configureCarrierFileFilter() { List<String> supportedFileFormats = new ArrayList<String>(); supportedFileFormats.add("bmp"); supportedFileFormats.add("git"); supportedFileFormats.add("jpeg"); supportedFileFormats.add("jpg"); supportedFileFormats.add("png"); supportedFileFormats.add("wbmp"); return new SuffixFileFilter(supportedFileFormats); }
From source file:com.siemens.scr.avt.ad.io.AnnotationBatchLoader.java
private void parseSegDicomFromDirectroy(File directory) throws IOException { Iterator<File> fileIterator = FileUtils.iterateFiles(directory, new SuffixFileFilter(".dcm"), TrueFileFilter.INSTANCE);/*from w ww . ja v a 2 s .c om*/ while (fileIterator.hasNext()) { File file = fileIterator.next(); DicomObject dob = DicomParser.read(file); if (dob == null) continue; String dicomUID = dob.getString(Tag.MediaStorageSOPInstanceUID); sopInstanceUID2URL.put(dicomUID, file); } }
From source file:algorithm.OpenStegoRandomLSBSteganography.java
@Override SuffixFileFilter configureDecapsulationFileFilter() { List<String> supportedFileFormats = new ArrayList<String>(); supportedFileFormats.add("png"); return new SuffixFileFilter(supportedFileFormats); }
From source file:algorithm.JPEGTextAdding.java
@Override SuffixFileFilter configureCarrierFileFilter() { ArrayList<String> supportedFormats = new ArrayList<String>(); supportedFormats.add("jpg"); supportedFormats.add("JPG"); supportedFormats.add("JPEG"); supportedFormats.add("jpeg"); return new SuffixFileFilter(supportedFormats); }
From source file:io.insideout.stanbol.enhancer.nlp.freeling.Freeling.java
@SuppressWarnings("unchecked") public Freeling(final String configurationPath, final String configurationFilenameSuffix, final String freelingSharePath, final String freelingLibPath, final String locale, final int maxInitThreads, final int poolSize, final int minQueueSize) { //determine the supported languages File configDir = new File(configurationPath); if (!configDir.isDirectory()) { throw new IllegalArgumentException( "The parsed configDirectory '" + configDir + "' is not a directory!"); }/* w w w .ja v a 2 s. com*/ log.info("Reading Freeling Configuration from Directory: {}", configDir); Map<String, File> supportedLanguages = new HashMap<String, File>(); String langIdConfigFile = null; if (configDir.isDirectory()) { for (File confFile : (Collection<File>) FileUtils.listFiles(configDir, new SuffixFileFilter(configurationFilenameSuffix), null)) { Properties prop = new Properties(); InputStream in = null; try { in = new FileInputStream(confFile); prop.load(in); String lang = prop.getProperty("Lang"); String langIdentFileName = prop.getProperty("LangIdentFile"); if (lang != null) { //not a Analyzer config File existing = supportedLanguages.get(lang); if (existing == null) { log.info(" ... adding language '{}' with config {}", lang, confFile); supportedLanguages.put(lang, confFile); } else { //two configs for the same language //take the one that is more similar to the language name int eld = StringUtils.getLevenshteinDistance(lang, FilenameUtils.getBaseName(existing.getName())); int cld = StringUtils.getLevenshteinDistance(lang, FilenameUtils.getBaseName(confFile.getName())); if (cld < eld) { log.info(" ... setting language '{}' to config {}", lang, confFile); supportedLanguages.put(lang, confFile); } } } else if (langIdentFileName != null) { if (langIdentFileName.startsWith("$FREELING")) { langIdentFileName = FilenameUtils.concat(freelingSharePath, langIdentFileName.substring(langIdentFileName.indexOf(File.separatorChar) + 1)); } if (langIdConfigFile != null) { log.warn( "Multiple LanguageIdentification configuration files. " + "Keep using '{}' and ignore '{}'!", langIdConfigFile, langIdentFileName); } else { log.info(" ... setting language identification config to '{}'", langIdentFileName); langIdConfigFile = langIdentFileName; } } } catch (IOException e) { log.error("Unable to read configuration file " + confFile, e); } finally { IOUtils.closeQuietly(in); } } } //init the ThreadPool used to create Freeling components //this is mainly needed for beeing able to ensure that only one Freeling //component is created at a time. This may be necessary in some //environment to avoid random crashes. freelingInitThreadPool = Executors .newFixedThreadPool(maxInitThreads <= 0 ? DEFAULT_CONCURRENT_THREADS : maxInitThreads); //Init the Analyzers if (supportedLanguages.isEmpty()) { log.warn("The parsed configDirectory '{}' does not contain any valid " + "language configuration (*.{}) files!", configDir, configurationFilenameSuffix); } else { AnalyzerFactory analyzerFactory = new AnalyzerFactory(freelingLibPath, freelingSharePath, locale, freelingInitThreadPool); //now init the ResourcePool(s) log.info("init ResourcePools (size: " + poolSize + ")"); for (Entry<String, File> supported : supportedLanguages.entrySet()) { Map<String, Object> context = new HashMap<String, Object>(); context.put(AnalyzerFactory.PROPERTY_LANGUAGE, supported.getKey()); context.put(AnalyzerFactory.PROPERTY_CONFIG_FILE, supported.getValue()); log.debug(" ... create ResourcePool for {}", context); analyzerPools.put(supported.getKey(), new ResourcePool<Analyzer>(poolSize, minQueueSize, analyzerFactory, context)); } } if (langIdConfigFile == null) { log.warn( "The parsed configDirectory '{}' does not contain the " + "Language Identification Component configuration (a *.{}) file! " + "Language Identification Service will not ba available.", configDir, configurationFilenameSuffix); langIdPool = null; } else { LangIdFactory langIdFactory = new LangIdFactory(freelingLibPath, langIdConfigFile, locale, freelingInitThreadPool); //Finally init the language identifier resource pool langIdPool = new ResourcePool<LanguageIdentifier>(poolSize, minQueueSize, langIdFactory, null); } }
From source file:name.martingeisse.ecobuild.moduletool.eco32.KernelTool.java
/** * Collects all .c and .s source files from the source folder. * //from w w w . ja v a 2 s .com * This method treats two files, start.s and end.s, specially: If present, * they are always listed first and last, respectively, in the source file * list. This is required for OS kernels to place code at reset/interrupt/TLB * entry points and place labels at the end of the kernel code. * * @param sourceFolder the module source folder * @return a string containing all source file names */ private String getSourceFileList(File sourceFolder) { StringBuilder builder = new StringBuilder(); for (String cfile : sourceFolder.list(new SuffixFileFilter(".c"))) { builder.append(cfile).append(' '); } boolean start = false, end = false; for (String sfile : sourceFolder.list(new SuffixFileFilter(".s"))) { if (sfile.equals("start.s")) { start = true; } else if (sfile.equals("end.s")) { end = true; } else { builder.append(sfile).append(' '); } } return ((start ? "start.s " : "") + builder + (end ? " end.s" : "")); }