if (src.toString().matches(".*" + Path.SEPARATOR + SCRATCH_DIR_NAME + "\\d\\.?\\d+.*")){ String diff = StringUtils.difference(src.toString(), dest.toString()); fs.delete(new Path(StringUtils.substringBefore(src.toString(), diff)), true); } else {
@SuppressWarnings("unchecked") private Collection<File> filterRelativeFiles(File sourceDirectory, IOFileFilter filter, boolean recurse) { Collection<File> files = listFiles(sourceDirectory, makeFileOnly(filter), (recurse ? makeDirectoryOnly(filter) : null)); Collection<File> relativeFiles = new ArrayList<File>(); String sourceDirectoryPath = sourceDirectory.getPath(); for (File file : files) { String filePath = file.getPath(); String relativePath = difference(sourceDirectoryPath, filePath); relativeFiles.add(new File(relativePath)); } return relativeFiles; }
/** * Retrieve the read/write component list with PVOB * * @param clearToolLauncher * @param filePath * @return the read/write component like 'DeskCore@\P_ORC DeskShared@\P_ORC build_Product@\P_ORC' * @throws IOException * @throws InterruptedException * @throws Exception */ private List<String> getReadWriteComponent(ClearTool clearTool, String viewTag) throws IOException, InterruptedException { String output = clearTool.lsproject(viewTag, "%[mod_comps]Xp"); final String prefix = "component:"; if (StringUtils.startsWith(output, prefix)) { List<String> componentNames = new ArrayList<String>(); String[] componentNamesSplit = output.split(" "); for (String componentName : componentNamesSplit) { String componentNameTrimmed = StringUtils.difference(prefix, componentName).trim(); if (StringUtils.isNotEmpty(componentNameTrimmed)) { componentNames.add(componentNameTrimmed); } } return componentNames; } throw new IOException(output); }
static String formatRightDiff(String key, String left, String right) { if (right.length() <= MAX_VALUE_LENGTH) { return formatValue(key, right); } String diff = StringUtils.difference(left, right); if (right.startsWith(diff)) { return formatValue(key, diff); } else { return formatValue(key, "..." + diff); } }
/** * Consumes two strings and returns true if the strings are within a tolerable * small Levenshtein-distance. * * @param s1 string 1 * @param s2 string 2 * @return True, if s1 has a tolerable small Levenshtein distance to s2. */ public static boolean smallLevenshtein(String s1, String s2) { s1 = normalizeString(s1); s2 = normalizeString(s2); if (Math.abs(s1.length() - s2.length()) > 2) { return false; } String difference = org.apache.commons.lang.StringUtils.difference(s1, s2); switch (difference.length()) { case 0: return true; case 1: // for english plural return difference.equals("s"); default: return false; } }
static String formatLeftDiff(String key, String left, String right) { if (left.length() <= MAX_VALUE_LENGTH) { return formatValue(key, left); } String diff = StringUtils.difference(right, left); if (left.startsWith(diff)) { return formatValue(key, diff); } else { return formatValue(key, "..." + diff); } }
/** * Retrieve all Clearcase UCM component (with pvob suffix) for a stream * * @param stream the stream name like 'P_EngDesk_Product_3.2_int@\P_ORC' * @param clearTool the clearcase launcher * @return component list attached to the stream like ['DocGen_PapeeteDoc@\P_ORC','DocMgt_Modulo@\P_ORC'] * @throws IOException * @throws InterruptedException */ private List<String> getComponentList(ClearTool clearTool, String stream) throws IOException, InterruptedException { String output = clearTool.lsstream(stream, null, "\"%[components]XCp\""); String comp[] = output.split(",\\s"); List<String> result = new ArrayList<String>(); final String prefix = "component:"; for (String c : comp) { if (StringUtils.startsWith(c, prefix)) { result.add(StringUtils.difference(prefix, c)); } else { throw new IOException("Invalid format for component in output. Must starts with 'component:' : " + c); } } return result; }
/** * Get the component binding to the baseline * * @param clearToolLauncher * @param baselineName the baseline name like 'deskCore_3.2-146_2008-11-14_18-07-22.3543@\P_ORC' * @return the component name like 'Desk_Core@\P_ORC' * @throws InterruptedException * @throws IOException */ private String getComponentforBaseline(ClearTool clearTool, String baselineName) throws InterruptedException, IOException { String output = clearTool.lsbl(baselineName, "%[component]Xp"); String prefix = "component:"; if (StringUtils.startsWith(output, prefix)) { return StringUtils.difference(prefix, output); } throw new IOException("Incorrect output. Received " + output); }
String residual = StringUtils.difference(whole, phrase); if (residual.length()>0) { residual = residual.trim().replace(" +", " ").toLowerCase();
String residual = StringUtils.difference(whole, phrase); if (residual.length()>0) { residual = residual.trim().replace(" +", " ").toLowerCase();
temp2 = matcher.group(2); String residual = StringUtils.difference(matcher.group(0), phrase); String anchorStr = ""; if (residual.length()>0) {
temp2 = matcher.group(2); String residual = StringUtils.difference(matcher.group(0), phrase); String anchorStr = ""; if (residual.length()>0) {
if (src.toString().matches(".*" + Path.SEPARATOR + SCRATCH_DIR_NAME + "\\d\\.?\\d+.*")){ String diff = StringUtils.difference(src.toString(), dest.toString()); fs.delete(new Path(StringUtils.substringBefore(src.toString(), diff)), true); } else {