List of usage examples for org.apache.commons.io IOCase SYSTEM
IOCase SYSTEM
To view the source code for org.apache.commons.io IOCase SYSTEM.
Click Source Link
From source file:com.matteoveroni.model.copy.FilenameUtils.java
/** * Checks whether two filenames are equal after both have been normalized * and using the case rules of the system. * <p>/*from w ww . j av a2 s .co m*/ * Both filenames are first passed to {@link #normalize(String)}. * The check is then performed case-sensitive on Unix and * case-insensitive on Windows. * * @param filename1 the first filename to query, may be null * @param filename2 the second filename to query, may be null * @return true if the filenames are equal, null equals null * @see IOCase#SYSTEM */ public static boolean equalsNormalizedOnSystem(String filename1, String filename2) { return equals(filename1, filename2, true, IOCase.SYSTEM); }
From source file:com.matteoveroni.model.copy.FilenameUtils.java
/** * Checks a filename to see if it matches the specified wildcard matcher * using the case rules of the system./*ww w.j a v a 2s .co m*/ * <p> * The wildcard matcher uses the characters '?' and '*' to represent a * single or multiple (zero or more) wildcard characters. * This is the same as often found on Dos/Unix command lines. * The check is case-sensitive on Unix and case-insensitive on Windows. * <pre> * wildcardMatch("c.txt", "*.txt") --> true * wildcardMatch("c.txt", "*.jpg") --> false * wildcardMatch("a/b/c.txt", "a/b/*") --> true * wildcardMatch("c.txt", "*.???") --> true * wildcardMatch("c.txt", "*.????") --> false * </pre> * N.B. the sequence "*?" does not work properly at present in match strings. * * @param filename the filename to match on * @param wildcardMatcher the wildcard string to match against * @return true if the filename matches the wilcard string * @see IOCase#SYSTEM */ public static boolean wildcardMatchOnSystem(String filename, String wildcardMatcher) { return wildcardMatch(filename, wildcardMatcher, IOCase.SYSTEM); }
From source file:org.cytoscape.app.internal.manager.AppManager.java
private void setupAlterationMonitor() { // Set up the FileAlterationMonitor to install/uninstall apps when apps are moved in/out of the // installed/uninstalled app directories fileAlterationMonitor = new FileAlterationMonitor(2000L); File installedAppsPath = new File(getInstalledAppsPath()); FileAlterationObserver installAlterationObserver = new FileAlterationObserver(installedAppsPath, new SingleLevelFileFilter(installedAppsPath), IOCase.SYSTEM); final AppManager appManager = this; // Listen for events on the "installed apps" folder installAlterationObserver.addListener(new FileAlterationListenerAdaptor() { @Override//from w w w . j a v a 2 s . c o m public void onFileCreate(File file) { App parsedApp = null; try { parsedApp = appParser.parseApp(file); } catch (AppParsingException e) { return; } App registeredApp = null; for (App app : apps) { if (parsedApp.heuristicEquals(app)) { registeredApp = app; // Delete old file if it was still there File oldFile = registeredApp.getAppFile(); if (oldFile.exists() && !registeredApp.getAppFile().equals(parsedApp.getAppFile())) { FileUtils.deleteQuietly(oldFile); } // Update file reference to reflect file having been moved registeredApp.setAppFile(file); } } try { if (registeredApp == null) { apps.add(parsedApp); parsedApp.install(appManager); } else { registeredApp.install(appManager); } } catch (AppInstallException e) { logger.warn(e.getLocalizedMessage()); } fireAppsChangedEvent(); } @Override public void onFileChange(File file) { // Can treat file replacements/changes as old file deleted, new file added this.onFileDelete(file); this.onFileCreate(file); fireAppsChangedEvent(); } @Override public void onFileDelete(File file) { // System.out.println(file + " on delete"); DebugHelper.print(this + " installObserverDelete", file.getAbsolutePath() + " deleted."); for (App app : apps) { if (app.getAppFile().equals(file)) { app.setStatus(AppStatus.FILE_MOVED); } } fireAppsChangedEvent(); } }); FileAlterationObserver disableAlterationObserver = new FileAlterationObserver(getDisabledAppsPath(), new SingleLevelFileFilter(new File(getDisabledAppsPath())), IOCase.SYSTEM); // Listen for events on the "disabled apps" folder disableAlterationObserver.addListener(new FileAlterationListenerAdaptor() { @Override public void onFileCreate(File file) { App parsedApp = null; try { parsedApp = appParser.parseApp(file); } catch (AppParsingException e) { logger.warn(e.getLocalizedMessage()); return; } DebugHelper.print(this + " disableObserver Create", parsedApp.getAppName() + " parsed"); App registeredApp = null; for (App app : apps) { if (parsedApp.heuristicEquals(app)) { registeredApp = app; // Delete old file if it was still there // TODO: Possible rename from filename-2 to filename? File oldFile = registeredApp.getAppFile(); if (oldFile.exists() && !registeredApp.getAppFile().equals(parsedApp.getAppFile())) { DebugHelper.print(this + " disableObserverCreate", registeredApp.getAppName() + " moved from " + registeredApp.getAppFile().getAbsolutePath() + " to " + parsedApp.getAppFile().getAbsolutePath() + ". deleting: " + oldFile); FileUtils.deleteQuietly(oldFile); } // Update file reference to reflect file having been moved registeredApp.setAppFile(file); } } try { if (registeredApp == null) { apps.add(parsedApp); parsedApp.disable(appManager); } else { registeredApp.disable(appManager); } fireAppsChangedEvent(); } catch (AppDisableException e) { } // System.out.println(file + " on create"); } @Override public void onFileChange(File file) { // Can treat file replacements/changes as old file deleted, new file added this.onFileDelete(file); this.onFileCreate(file); fireAppsChangedEvent(); } @Override public void onFileDelete(File file) { // System.out.println(file + " on delete"); DebugHelper.print(this + " disableObserverDelete", file.getAbsolutePath() + " deleted."); for (App app : apps) { // System.out.println("checking " + app.getAppFile().getAbsolutePath()); if (app.getAppFile().equals(file)) { // System.out.println(app + " moved"); app.setStatus(AppStatus.FILE_MOVED); } } fireAppsChangedEvent(); } }); FileAlterationObserver uninstallAlterationObserver = new FileAlterationObserver(getUninstalledAppsPath(), new SingleLevelFileFilter(new File(getUninstalledAppsPath())), IOCase.SYSTEM); // Listen for events on the "uninstalled apps" folder uninstallAlterationObserver.addListener(new FileAlterationListenerAdaptor() { @Override public void onFileCreate(File file) { App parsedApp = null; try { parsedApp = appParser.parseApp(file); } catch (AppParsingException e) { return; } DebugHelper.print(this + " uninstallObserverCreate", parsedApp.getAppName() + " parsed"); App registeredApp = null; for (App app : apps) { if (parsedApp.heuristicEquals(app)) { registeredApp = app; // Delete old file if it was still there // TODO: Possible rename from filename-2 to filename? File oldFile = registeredApp.getAppFile(); if (oldFile.exists() && !registeredApp.getAppFile().equals(parsedApp.getAppFile())) { DebugHelper.print(this + " uninstallObserverCreate", registeredApp.getAppName() + " moved from " + registeredApp.getAppFile().getAbsolutePath() + " to " + parsedApp.getAppFile().getAbsolutePath() + ". deleting: " + oldFile); FileUtils.deleteQuietly(oldFile); } // Update file reference to reflect file having been moved registeredApp.setAppFile(file); } } try { // Checks if the app file moved here belonged to a known app, if so, uninstall it. if (registeredApp == null) { apps.add(parsedApp); parsedApp.uninstall(appManager); } else { registeredApp.uninstall(appManager); } fireAppsChangedEvent(); } catch (AppUninstallException e) { } // System.out.println(file + " on create"); } @Override public void onFileChange(File file) { // Can treat file replacements/changes as old file deleted, new file added this.onFileDelete(file); this.onFileCreate(file); fireAppsChangedEvent(); } @Override public void onFileDelete(File file) { // System.out.println(file + " on delete"); DebugHelper.print(this + " uninstallObserverDelete", file.getAbsolutePath() + " deleted."); for (App app : apps) { // System.out.println("checking " + app.getAppFile().getAbsolutePath()); if (app.getAppFile().equals(file)) { // System.out.println(app + " moved"); app.setStatus(AppStatus.FILE_MOVED); } } fireAppsChangedEvent(); } }); // setupKarafDeployMonitor(fileAlterationMonitor); try { installAlterationObserver.initialize(); fileAlterationMonitor.addObserver(installAlterationObserver); disableAlterationObserver.initialize(); fileAlterationMonitor.addObserver(disableAlterationObserver); uninstallAlterationObserver.initialize(); fileAlterationMonitor.addObserver(uninstallAlterationObserver); fileAlterationMonitor.start(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:org.eclipse.smila.utils.scriptexecution.WindowsScriptExecutor.java
/** * {@inheritDoc}/*from w w w. j a va2 s. c om*/ */ public int execute(final File file) throws IOException, InterruptedException { _log.debug("Executing " + file.getAbsolutePath()); final String fileName = file.getName(); final IOCase ioCase = IOCase.SYSTEM; if (!ioCase.checkEndsWith(fileName, ".cmd") && !ioCase.checkEndsWith(fileName, ".bat")) { _log.debug("It doesn't end with .cmd or .bat"); final File tempFile = getTempCmdFile(file.getParentFile()); try { _log.debug("Copy " + file.getAbsolutePath() + " to " + tempFile); FileUtils.copyFile(file, tempFile); return doExecute(tempFile); } finally { tempFile.delete(); } } else { return doExecute(file); } }
From source file:org.kalypso.afgui.internal.handlers.ScenarioData.java
/** * Returns names of all sub folders of the parent scenario. These folder (either are scenarios or ordinary data * folders) cannot be used as new scenario. *//*from w ww.j av a 2 s . co m*/ public Set<String> getExistingFolders() { final Comparator<String> ignoreCaseComparator = new Comparator<String>() { @Override public int compare(final String o1, final String o2) { // REMARK: using same case sensitive rules as the current file system. return IOCase.SYSTEM.checkCompareTo(o1, o2); } }; final Set<String> folders = new TreeSet<>(ignoreCaseComparator); final IFolder folder = m_parentScenario.getDerivedFolder(); try { if (folder.exists()) { final IResource[] members = folder.members(); for (final IResource member : members) { if (member instanceof IFolder) folders.add(member.getName()); } } } catch (final CoreException e) { e.printStackTrace(); // error handling? } return Collections.unmodifiableSet(folders); }
From source file:org.kalypso.commons.databinding.validation.FileNameIsUniqueValidator.java
@Override protected IStatus doValidate(final String value) throws CoreException { if (StringUtils.isEmpty(value)) return ValidationStatus.ok(); for (final String string : m_strings) { if (IOCase.SYSTEM.checkEquals(m_current, string)) continue; if (IOCase.SYSTEM.checkEquals(string, value)) fail();/*from w ww . j a v a2 s .c o m*/ } return ValidationStatus.ok(); }
From source file:org.kalypso.ui.rrm.internal.timeseries.operations.StoreTimeseriesOperation.java
private boolean fileNameExists(final String file) { final IStoreObservationData data = m_operation.getData(); final String[] existing = data.getExistingTimeserieses(); for (final String exists : existing) { if (IOCase.SYSTEM.checkEquals(exists, file)) return true; }//from w w w . j a v a 2 s . com return false; }
From source file:org.kalypso.ui.rrm.internal.timeseries.QualityUniqueValidator.java
@Override protected IStatus doValidate(final String value) throws CoreException { final String parameterType = m_parameterTypeProvider.getParameterType(); final String[] existingQualities = m_station.getQualities(parameterType); for (final String quality : existingQualities) { if (m_current != null && IOCase.SYSTEM.checkEquals(m_current, quality)) continue; if (IOCase.SYSTEM.checkEquals(quality, value)) fail();//from w ww. ja v a2 s. c om } return ValidationStatus.ok(); }
From source file:org.kalypso.ui.rrm.internal.timeseries.view.actions.TargetTimeseriesValidator.java
private ITimeseries[] filterByQuality(final ITimeseries[] timeserieses) { final String quality = getQuality(); final Set<ITimeseries> found = new LinkedHashSet<>(); for (final ITimeseries timeseries : timeserieses) { final String q = timeseries.getQuality(); if (Strings.isNullOrEmpty(quality) && Strings.isNullOrEmpty(q)) found.add(timeseries);//from w w w . j a v a2s . c o m else if (!Strings.isNullOrEmpty(quality) && Strings.isNullOrEmpty(q)) continue; else if (Strings.isNullOrEmpty(quality) && !Strings.isNullOrEmpty(q)) continue; else if (IOCase.SYSTEM.checkEquals(quality, q)) found.add(timeseries); } return found.toArray(new ITimeseries[] {}); }
From source file:org.kalypso.utils.shape.ShapeUtilities.java
/** * Find all files of a shape file (i.e. .shp, .dbf and ..shx), but only if they really exist. * /*from w w w . jav a 2s . co m*/ * @param shapeFile * Path to the file with extension '.shp'. */ public static IFile[] getExistingShapeFiles(final IFile shapeFile) throws CoreException { final IContainer parent = shapeFile.getParent(); final IPath basePath = shapeFile.getFullPath().removeFileExtension(); final String name = basePath.lastSegment(); final FileFilter filter = new NameFileFilter(new String[] { name + ShapeFile.EXTENSION_SHP, name + ShapeFile.EXTENSION_DBF, name + ShapeFile.EXTENSION_SHX }, IOCase.SYSTEM); final FileFilterVisitor visitor = new FileFilterVisitor(filter); parent.accept(visitor); return visitor.getFiles(); }