/** * Expand all supported variables and canonicalize (resolve ".." and ".") * a path. If the input path has no variables, it is returned unchanged. * rootDir and inputRootDir can be null. * @param path The path to expand * @param rootDir The directory to expand ${rootDir} into * @param inputRootDir The directory to expand ${inputRootDir} into * @return The expanded path * @throws IOException If canonicalizing fails */ public static String expandPath (String path, String rootDir, String inputRootDir) throws IOException { if (!path.contains("${")) return path; path = Util.fillSystemEnvars(path); path = Util.fillRootDirectoryVariable(path, rootDir); path = Util.fillInputRootDirectoryVariable(path, inputRootDir); path = new File(path).getCanonicalPath(); return path; }
/** * Generates the report file with the results. */ private void generateReport () { // Output the report PrintWriter writer = null; try { String finalPath = Util.fillRootDirectoryVariable(params.getOutputPath(), rootDir); finalPath = Util.fillInputRootDirectoryVariable(finalPath, inputRootDir); Util.createDirectories(finalPath); writer = new PrintWriter(finalPath, "UTF-8"); for ( Entry<String, Integer> entry : terms.entrySet() ) { writer.println(String.format("%d\t%s", entry.getValue(), entry.getKey())); } } catch ( IOException e ) { throw new OkapiException("Error when writing output file.", e); } finally { if ( writer != null ) { writer.close(); writer = null; } } }
private void generateReport (String text) { // Output the report PrintWriter writer = null; try { String finalPath = Util.fillRootDirectoryVariable(params.getLogPath(), rootDir); finalPath = Util.fillInputRootDirectoryVariable(finalPath, inputRootDir); Util.createDirectories(finalPath); writer = new PrintWriter(finalPath, "UTF-8"); writer.println(text); } catch ( IOException e ) { throw new OkapiException("Error when writing output file.", e); } finally { if ( writer != null ) { writer.close(); writer = null; } } }
propFile = propFile.trim(); propFile = Util.fillRootDirectoryVariable(propFile, rootDir); propFile = Util.fillInputRootDirectoryVariable(propFile, inputRootDir); propFile = LocaleId.replaceVariables(propFile, sourceLocale, targetLocale);
finalPath = Util.fillInputRootDirectoryVariable(finalPath, inputRootDir); replacementWords = loadList(finalPath);
origin = Util.fillInputRootDirectoryVariable(origin, inputRootDir); origin = LocaleId.replaceVariables(origin, manifest.getSourceLocale(), manifest.getTargetLocale());
tmxOutputPath = Util.fillInputRootDirectoryVariable(tmxOutputPath, inputRootDir); tmxOutputPath = LocaleId.replaceVariables(tmxOutputPath, srcLoc, trgLoc); existingTMPath = Util.fillInputRootDirectoryVariable(existingTMPath, inputRootDir); existingTMPath = LocaleId.replaceVariables(existingTMPath, srcLoc, trgLoc); existingTm = TmSeekerFactory.createFileBasedTmSeeker(existingTMPath); SRXDocument srxDoc = new SRXDocument(); String srxPath = Util.fillRootDirectoryVariable(params.getSrxPath(), rootDir); srxPath = Util.fillInputRootDirectoryVariable(srxPath, inputRootDir); srxPath = LocaleId.replaceVariables(srxPath, srcLoc, trgLoc); srxDoc.loadRules(srxPath);
resolvedOutputDir = Util.fillInputRootDirectoryVariable(resolvedOutputDir, inputRootDir); resolvedOutputDir = LocaleId.replaceVariables(resolvedOutputDir, srcLoc, trgLoc);
resolvedPath = Util.fillInputRootDirectoryVariable(resolvedPath, inputRootDir); resolvedPath = LocaleId.replaceVariables(resolvedPath, sourceLocale, targetLocale); tmx = new TMXWriter(resolvedPath);
tmxOutputPath = Util.fillInputRootDirectoryVariable(tmxOutputPath, inputRootDir); tmxOutputPath = LocaleId.replaceVariables(tmxOutputPath, sourceLocale, targetLocale); tmxWriter = new TMXWriter(tmxOutputPath);
tmDir = Util.fillInputRootDirectoryVariable(tmDir, inputRootDir); tmDir = LocaleId.replaceVariables(tmDir, srcLoc, trgLoc); Util.createDirectories(tmDir+File.separator);
realPath = Util.fillInputRootDirectoryVariable(realPath, inputRootDir); realPath = LocaleId.replaceVariables(realPath, sourceLocale, targetLocale);
src = Util.fillInputRootDirectoryVariable(src, inputRootDir); srxDoc.loadRules(src); } else { trg = Util.fillInputRootDirectoryVariable(trg, inputRootDir);