List of usage examples for org.apache.commons.io IOCase INSENSITIVE
IOCase INSENSITIVE
To view the source code for org.apache.commons.io IOCase INSENSITIVE.
Click Source Link
From source file:org.kalypso.model.wspm.tuhh.schema.simulation.QIntervalReader.java
private void readResults() throws IOException { /* Read w-points first: PROFxxx.xxxx.txt files */ final FilenameFilter filter = new WildcardFileFilter("PROF*.txt", IOCase.INSENSITIVE); //$NON-NLS-1$ final File[] profFiles = m_inputDir.listFiles(filter); if (profFiles == null || profFiles.length == 0) { m_log.finish(IStatus.ERROR,/*w w w .j a va 2s.c om*/ Messages.getString("org.kalypso.model.wspm.tuhh.schema.simulation.PolynomeProcessor.17")); //$NON-NLS-1$ return; } read(profFiles); if (m_log.checkCanceled()) return; final PolynomeReader polynomeReader = new PolynomeReader(m_intervalIndex, m_log); polynomeReader.read(new File(m_inputDir, "Polynome.TXT")); //$NON-NLS-1$ final BuildingPolygonReader buildingReader = new BuildingPolygonReader(m_intervalIndex, m_log); buildingReader.read(new File(m_inputDir, PolynomeProcessor.WEIR_FILE_NAME)); buildingReader.read(new File(m_inputDir, PolynomeProcessor.BRIDGE_FILE_NAME)); if (m_log.checkCanceled()) return; }
From source file:org.kalypso.risk.model.simulation.statistics.StatisticCalculationData.java
/** * Finds all available polygon shapes and lists their attributes that are either character or numeric. *//*from ww w . j a v a2 s . co m*/ private void initAvailableShapes() { if (m_scenarioFolder == null) return; final IProject project = m_scenarioFolder.getProject(); final IFolder shapeFolder = project.getFolder("imports").getFolder("basemap"); //$NON-NLS-1$ //$NON-NLS-2$ if (!shapeFolder.exists()) return; final File shapeDir = shapeFolder.getLocation().toFile(); final IOFileFilter shpFilter = FileFilterUtils.suffixFileFilter(ShapeFile.EXTENSION_SHP, IOCase.INSENSITIVE); //$NON-NLS-1$ final File[] shapeFiles = shapeDir.listFiles((FilenameFilter) shpFilter); if (shapeFiles == null) return; m_availableShapeFiles.put(SHAPE_FILE_NONE, new String[] { StringUtils.EMPTY }); for (final File shpFile : shapeFiles) { final String shpBase = FilenameUtils.removeExtension(shpFile.getAbsolutePath()); try (final ShapeFile shapeFile = new ShapeFile(shpBase, Charset.defaultCharset(), FileMode.READ)) { final ShapeType shapeType = shapeFile.getShapeType(); if (shapeType == ShapeType.POLYGON || shapeType == ShapeType.POLYGONZ) { final Set<String> attributes = new HashSet<>(); final IDBFField[] fields = shapeFile.getFields(); for (final IDBFField field : fields) { final FieldType type = field.getType(); if (type == FieldType.C || type == FieldType.N) attributes.add(field.getName()); } if (attributes.size() == 0) m_availableShapeFiles.put(shpFile, NO_ATTRIBUTES); else m_availableShapeFiles.put(shpFile, attributes.toArray(new String[attributes.size()])); } } catch (final IOException e) { e.printStackTrace(); } catch (final DBaseException e) { e.printStackTrace(); } } m_selectedShape = m_availableShapeFiles.keySet().iterator().next(); }
From source file:org.kie.guvnor.m2repo.backend.server.GuvnorM2Repository.java
/** * Finds files within the repository with the given filters. * * @param filters filter to apply when finding files. The filter is used to create a wildcard matcher, ie., "*fileter*.*", in which "*" is * to represent a multiple wildcard characters. * @return an collection of java.io.File with the matching files *//* w w w. j ava2s . c o m*/ public Collection<File> listFiles(String filters) { String wildcard = "*.jar"; if (filters != null) { wildcard = "*" + filters + "*.jar"; } Collection<File> files = FileUtils.listFiles(new File(M2_REPO_ROOT), new WildcardFileFilter(wildcard, IOCase.INSENSITIVE), DirectoryFileFilter.DIRECTORY); return files; }
From source file:org.kuali.kfs.sys.businessobject.lookup.BatchFileLookupableHelperServiceImpl.java
protected IOFileFilter getFileNameBasedFilter(String fileNamePattern) { if (StringUtils.isNotBlank(fileNamePattern)) { return new WildcardFileFilter(fileNamePattern, IOCase.INSENSITIVE); }//w w w . ja v a2s. c o m return null; }
From source file:org.liberty.android.fantastischmemo.converter.Mnemosyne2CardsExporter.java
@Override public void convert(String src, String dest) throws Exception { // Make the tmp directory tmp/[src file name]/ String srcFilename = FilenameUtils.getName(src); // This the file name for cards without extension String deckName = FilenameUtils.removeExtension(srcFilename); File tmpDirectory = new File(AMEnv.DEFAULT_TMP_PATH + deckName); FileUtils.deleteDirectory(tmpDirectory); FileUtils.forceMkdir(tmpDirectory);/*from w ww . j a v a 2s . c om*/ try { // Example content of cards // $ ls // METADATA cards.xml musicnotes // Make sure the XML file exists. File xmlFile = new File(tmpDirectory + "/cards.xml"); // Before opening dest. Try to backup and delete the dest db. amFileUtil.deleteFileWithBackup(dest); createXMLFile(src, xmlFile); File metadataFile = new File(tmpDirectory + "/METADATA"); createMetadata(deckName, metadataFile); // The last step is to see if there are images to export. File imageDir = new File(AMEnv.DEFAULT_IMAGE_PATH + srcFilename); if (imageDir.exists() && imageDir.isDirectory()) { // Copy all the images to the tmp directory Collection<File> imageFiles = FileUtils.listFiles(imageDir, new SuffixFileFilter(new String[] { "jpg", "png", "bmp", "jpeg" }, IOCase.INSENSITIVE), DirectoryFileFilter.DIRECTORY); for (File f : imageFiles) { FileUtils.copyFileToDirectory(f, tmpDirectory); } } // Now create the cards file: AMZipUtils.zipDirectory(tmpDirectory, "", new File(dest)); } finally { FileUtils.deleteDirectory(tmpDirectory); } }
From source file:org.liberty.android.fantastischmemo.converter.Mnemosyne2CardsImporter.java
@Override public void convert(String src, String dest) throws Exception { // Make the tmp directory tmp/[src file name]/ String srcFilename = FilenameUtils.getName(src); File tmpDirectory = new File(AMEnv.DEFAULT_TMP_PATH + srcFilename); FileUtils.deleteDirectory(tmpDirectory); FileUtils.forceMkdir(tmpDirectory);/* w ww . j a va2s. c o m*/ AnyMemoDBOpenHelper helper = null; try { // First unzip the file since cards is just a zip archive // Example content of cards // $ ls // METADATA cards.xml musicnotes AMZipUtils.unZipFile(new File(src), tmpDirectory); // Make sure the XML file exists. File xmlFile = new File(tmpDirectory + "/cards.xml"); if (!xmlFile.exists()) { throw new Exception("Could not find the cards.xml after extracting " + src); } List<Card> cardList = xmlToCards(xmlFile); if (!new File(dest).exists()) { amFileUtil.createDbFileWithDefaultSettings(new File(dest)); } helper = AnyMemoDBOpenHelperManager.getHelper(dest); CardDao cardDao = helper.getCardDao(); cardDao.createCards(cardList); // The last step is to see if there are images to import. Collection<File> imageFiles = FileUtils.listFiles(tmpDirectory, new SuffixFileFilter(new String[] { "jpg", "png", "bmp" }, IOCase.INSENSITIVE), DirectoryFileFilter.DIRECTORY); if (!imageFiles.isEmpty()) { String destDbName = FilenameUtils.getName(dest); File imageDir = new File(AMEnv.DEFAULT_IMAGE_PATH + destDbName); FileUtils.forceMkdir(imageDir); for (File imageFile : imageFiles) { FileUtils.copyFileToDirectory(imageFile, imageDir); } } } finally { if (helper != null) { AnyMemoDBOpenHelperManager.releaseHelper(helper); } FileUtils.deleteDirectory(tmpDirectory); } }
From source file:org.mule.el.function.WildcardExpressionLanguageFuntion.java
protected boolean isMatch(String wildcardPattern, String text, boolean caseSensitive) { return FilenameUtils.wildcardMatch(text, wildcardPattern, caseSensitive ? IOCase.SENSITIVE : IOCase.INSENSITIVE); }
From source file:org.mycontroller.standalone.api.BackupApi.java
/** * Call this method to get list of available backup files. * <p><b>Filter(s):</b> * <p>name - {@link List} of backup file names * <p><b>Page filter(s):</b> * <p>pageLimit - Set number of items per page * <p>page - Request page number/*w ww. j ava 2s . c o m*/ * <p>order - Set order. <b>Option:</b> asc, desc * <p>orderBy - column name for order. <b>Option:</b> name * @param filters Supports various filter options. * @return QueryResponse Contains input filter and response * @throws IOException throws when problem with backup location */ public QueryResponse getBackupFiles(HashMap<String, Object> filters) throws IOException { Query query = Query.get(filters); String locationCanonicalPath = McUtils.getDirectoryLocation(FileUtils .getFile(AppProperties.getInstance().getBackupSettings().getBackupLocation()).getCanonicalPath()); if (FileUtils.getFile(locationCanonicalPath).exists()) { List<BackupFile> files = new ArrayList<BackupFile>(); //Filters //Extension filter SuffixFileFilter extensionFilter = new SuffixFileFilter(BACKUP_FILE_SUFFIX_FILTER, IOCase.INSENSITIVE); //name filter IOFileFilter nameFileFilter = null; @SuppressWarnings("unchecked") List<String> fileNames = (List<String>) query.getFilters().get(KEY_NAME); if (fileNames == null) { fileNames = new ArrayList<String>(); } fileNames.add(BRCommons.FILE_NAME_IDENTITY); if (fileNames != null && !fileNames.isEmpty()) { for (String fileName : fileNames) { if (nameFileFilter == null) { nameFileFilter = FileFilterUtils .and(new WildcardFileFilter("*" + fileName + "*", IOCase.INSENSITIVE)); } else { nameFileFilter = FileFilterUtils.and(nameFileFilter, new WildcardFileFilter("*" + fileName + "*", IOCase.INSENSITIVE)); } } } //Combine all filters IOFileFilter finalFileFilter = null; if (nameFileFilter != null) { finalFileFilter = FileFilterUtils.and(extensionFilter, nameFileFilter); } else { finalFileFilter = extensionFilter; } List<File> backupFiles = new ArrayList<File>(FileUtils .listFiles(FileUtils.getFile(locationCanonicalPath), finalFileFilter, TrueFileFilter.INSTANCE)); query.setFilteredCount((long) backupFiles.size()); //Get total items without filter query.setTotalItems((long) FileUtils .listFiles(FileUtils.getFile(locationCanonicalPath), extensionFilter, TrueFileFilter.INSTANCE) .size()); int fileFrom; int fileTo; if (query.getPageLimit() == -1) { fileTo = backupFiles.size(); fileFrom = 0; } else { fileFrom = query.getStartingRow().intValue(); fileTo = (int) (query.getPage() * query.getPageLimit()); } for (File backupFile : backupFiles) { String name = backupFile.getCanonicalPath().replace(locationCanonicalPath, ""); files.add(BackupFile.builder().name(name).size(backupFile.length()) .timestamp(backupFile.lastModified()).canonicalPath(backupFile.getCanonicalPath()).build()); } if (!files.isEmpty()) { //Do order reverse Collections.sort(files, Collections.reverseOrder()); if (fileFrom < files.size()) { files = files.subList(Math.max(0, fileFrom), Math.min(fileTo, files.size())); } } return QueryResponse.builder().data(files).query(query).build(); } else { throw new FileNotFoundException("File location not found: " + locationCanonicalPath); } }
From source file:org.mycontroller.standalone.utils.McScriptFileUtils.java
@SuppressWarnings("unchecked") public static QueryResponse getScriptFiles(Query query) throws IOException { //Check less info available and true, if true set less info return Boolean lessInfo = (Boolean) query.getFilters().get(ScriptsHandler.KEY_LESS_INFO); if (lessInfo) { query.setPageLimit(-1);//from w w w. j a v a2s. c om } String scriptsFileLocation = AppProperties.getInstance().getScriptsLocation(); String filesLocation = null; if (query.getFilters().get(ScriptsHandler.KEY_TYPE) == null) { filesLocation = scriptsFileLocation; } else if (query.getFilters().get(ScriptsHandler.KEY_TYPE) == SCRIPT_TYPE.CONDITION) { filesLocation = AppProperties.getInstance().getScriptsConditionsLocation(); } else if (query.getFilters().get(ScriptsHandler.KEY_TYPE) == SCRIPT_TYPE.OPERATION) { filesLocation = AppProperties.getInstance().getScriptsOperationsLocation(); } String locationCanonicalPath = McUtils .getDirectoryLocation(FileUtils.getFile(scriptsFileLocation).getCanonicalPath()); if (FileUtils.getFile(filesLocation).exists()) { List<McScript> files = new ArrayList<McScript>(); List<String> filesString = new ArrayList<String>(); //Filters //Extension filter String[] scriptSuffixFilter = null; if (query.getFilters().get(ScriptsHandler.KEY_EXTENSION) != null) { if (Arrays.asList(MC_SCRIPT_SUFFIX_FILTER) .contains(query.getFilters().get(ScriptsHandler.KEY_EXTENSION))) { scriptSuffixFilter = new String[] { (String) query.getFilters().get(ScriptsHandler.KEY_EXTENSION) }; } } if (scriptSuffixFilter == null) { scriptSuffixFilter = MC_SCRIPT_SUFFIX_FILTER; } SuffixFileFilter languageFilter = new SuffixFileFilter(scriptSuffixFilter, IOCase.INSENSITIVE); //name filter IOFileFilter nameFileFilter = null; List<String> fileNames = (List<String>) query.getFilters().get(ScriptsHandler.KEY_NAME); if (fileNames != null && !fileNames.isEmpty()) { for (String fileName : fileNames) { if (nameFileFilter == null) { nameFileFilter = FileFilterUtils .and(new WildcardFileFilter("*" + fileName + "*", IOCase.INSENSITIVE)); } else { nameFileFilter = FileFilterUtils.and(nameFileFilter, new WildcardFileFilter("*" + fileName + "*", IOCase.INSENSITIVE)); } } } //Combine all filters IOFileFilter scriptsFileFilter = null; if (nameFileFilter != null) { scriptsFileFilter = FileFilterUtils.and(languageFilter, nameFileFilter); } else { scriptsFileFilter = languageFilter; } List<File> scriptFiles = new ArrayList<File>(FileUtils.listFiles(FileUtils.getFile(filesLocation), scriptsFileFilter, TrueFileFilter.INSTANCE)); query.setFilteredCount((long) scriptFiles.size()); //Get total items without filter query.setTotalItems((long) FileUtils.listFiles(FileUtils.getFile(scriptsFileLocation), new SuffixFileFilter(MC_SCRIPT_SUFFIX_FILTER, IOCase.INSENSITIVE), TrueFileFilter.INSTANCE) .size()); int fileFrom; int fileTo; if (query.getPageLimit() == -1) { fileTo = scriptFiles.size(); fileFrom = 0; } else { fileFrom = query.getStartingRow().intValue(); fileTo = (int) (query.getPage() * query.getPageLimit()); } for (; fileFrom < fileTo; fileFrom++) { if (scriptFiles.size() > fileFrom) { File scriptFile = scriptFiles.get(fileFrom); String name = scriptFile.getCanonicalPath().replace(locationCanonicalPath, ""); if (lessInfo) { filesString.add(name); } else { files.add(McScript.builder().name(name) .extension(FilenameUtils.getExtension(scriptFile.getCanonicalPath())) .size(scriptFile.length()).lastModified(scriptFile.lastModified()).build()); } } else { break; } } if (lessInfo) { return QueryResponse.builder().data(filesString).query(query).build(); } else { return QueryResponse.builder().data(files).query(query).build(); } } else { throw new FileNotFoundException("File location not found: " + locationCanonicalPath); } }
From source file:org.mycontroller.standalone.utils.McServerFileUtils.java
public static List<String> getImageFilesList() throws IOException { String filesLocation = AppProperties.getInstance().getControllerSettings().getWidgetImageFilesLocation(); String locationCanonicalPath = FileUtils.getFile(filesLocation).getCanonicalPath(); if (!locationCanonicalPath.endsWith(File.separator)) { locationCanonicalPath += File.separator; }//from w ww . j av a2 s . co m if (FileUtils.getFile(filesLocation).exists()) { List<String> files = new ArrayList<String>(); IOFileFilter ioFileFilter = FileFilterUtils.and( new SuffixFileFilter(IMAGE_DISPLAY_SUFFIX_FILTER, IOCase.INSENSITIVE), new SizeFileFilter(IMAGE_DISPLAY_WIDGET_FILE_SIZE_LIMIT, false)); Collection<File> imageFiles = FileUtils.listFiles(FileUtils.getFile(filesLocation), ioFileFilter, TrueFileFilter.INSTANCE); for (File imageFile : imageFiles) { files.add(imageFile.getCanonicalPath().replace(locationCanonicalPath, "")); if (files.size() >= MAX_FILES_LIMIT) { break; } } return files; } else { throw new FileNotFoundException("File location not found: " + locationCanonicalPath); } }