return str1; final int at = indexOfDifference(str1, str2); if (at == INDEX_NOT_FOUND) { return EMPTY;
return EMPTY; final int smallestIndexOfDiff = indexOfDifference(strs); if (smallestIndexOfDiff == INDEX_NOT_FOUND) {
public String match() { if (startTime == null || endTime == null) return StringUtils.EMPTY; String sString = startTime.toEpochMilli() + ""; String eString = endTime.toEpochMilli() + ""; int diff = StringUtils.indexOfDifference(sString, eString); if (diff < 0) return sString; return sString.substring(0, diff); }
/** Given a date range, find a common string prefix Eg: 20120212, 20120213 = 2012021 */ protected String match(Date start, Date end) { String sString = DateUtil.formatyyyyMMddHHmm(start); // formatDate(start); String eString = DateUtil.formatyyyyMMddHHmm(end); // formatDate(end); int diff = StringUtils.indexOfDifference(sString, eString); if (diff < 0) return sString; return sString.substring(0, diff); }
@Test public void testDifferenceAt_StringString() { assertEquals(-1, StringUtils.indexOfDifference(null, null)); assertEquals(0, StringUtils.indexOfDifference(null, "i am a robot")); assertEquals(-1, StringUtils.indexOfDifference("", "")); assertEquals(0, StringUtils.indexOfDifference("", "abc")); assertEquals(0, StringUtils.indexOfDifference("abc", "")); assertEquals(0, StringUtils.indexOfDifference("i am a machine", null)); assertEquals(7, StringUtils.indexOfDifference("i am a machine", "i am a robot")); assertEquals(-1, StringUtils.indexOfDifference("foo", "foo")); assertEquals(0, StringUtils.indexOfDifference("i am a robot", "you are a robot")); }
@Test public void testDifferenceAt_StringArray() { assertEquals(-1, StringUtils.indexOfDifference((String[]) null)); assertEquals(-1, StringUtils.indexOfDifference(new String[]{})); assertEquals(-1, StringUtils.indexOfDifference(new String[]{"abc"})); assertEquals(-1, StringUtils.indexOfDifference(new String[]{null, null})); assertEquals(-1, StringUtils.indexOfDifference(new String[]{"", ""})); assertEquals(0, StringUtils.indexOfDifference(new String[]{"", null})); assertEquals(0, StringUtils.indexOfDifference(new String[]{"abc", null, null})); assertEquals(0, StringUtils.indexOfDifference(new String[]{null, null, "abc"})); assertEquals(0, StringUtils.indexOfDifference(new String[]{"", "abc"})); assertEquals(0, StringUtils.indexOfDifference(new String[]{"abc", ""})); assertEquals(-1, StringUtils.indexOfDifference(new String[]{"abc", "abc"})); assertEquals(1, StringUtils.indexOfDifference(new String[]{"abc", "a"})); assertEquals(2, StringUtils.indexOfDifference(new String[]{"ab", "abxyz"})); assertEquals(2, StringUtils.indexOfDifference(new String[]{"abcde", "abxyz"})); assertEquals(0, StringUtils.indexOfDifference(new String[]{"abcde", "xyz"})); assertEquals(0, StringUtils.indexOfDifference(new String[]{"xyz", "abcde"})); assertEquals(7, StringUtils.indexOfDifference(new String[]{"i am a machine", "i am a robot"})); }
return str1; final int at = indexOfDifference(str1, str2); if (at == INDEX_NOT_FOUND) { return EMPTY;
return str1; final int at = indexOfDifference(str1, str2); if (at == INDEX_NOT_FOUND) { return EMPTY;
return str1; final int at = indexOfDifference(str1, str2); if (at == INDEX_NOT_FOUND) { return EMPTY;
return EMPTY; final int smallestIndexOfDiff = indexOfDifference(strs); if (smallestIndexOfDiff == INDEX_NOT_FOUND) {
public static Node getNearestContentByTemplateCategorySubCategory(Node siteRoot, String category, String subCategory, Node current) throws RepositoryException { List<Node> nodeList = getContentListByTemplateCategorySubCategory(siteRoot, category, subCategory); if (!nodeList.isEmpty()) { Node bestMatching = null; int bestMatchingLength = -1; for (Node node : nodeList) { int matchingLegth = StringUtils.indexOfDifference(node.getPath(), current.getPath()); if (matchingLegth > bestMatchingLength) { bestMatchingLength = matchingLegth; bestMatching = node; } } return bestMatching; } return null; } }
return EMPTY; final int smallestIndexOfDiff = indexOfDifference(strs); if (smallestIndexOfDiff == INDEX_NOT_FOUND) {
return EMPTY; final int smallestIndexOfDiff = indexOfDifference(strs); if (smallestIndexOfDiff == INDEX_NOT_FOUND) {
public void setFail(String property, Object a, Object b) { this.fail = property; String aStr = a.toString(); String bStr = b.toString(); int diffPos = StringUtils.indexOfDifference(aStr, bStr); if (diffPos < 0) { this.a = aStr; this.b = bStr; return; } String aDiff = aStr.substring(diffPos); String bDiff = bStr.substring(diffPos); this.a = truncate(aStr, aDiff, diffPos); this.b = truncate(bStr, bDiff, diffPos); }
public static int indexOfDifference(ActionContext actionContext){ Thing self = actionContext.getObject("self"); CharSequence cs1 = (CharSequence) self.doAction("getCs1", actionContext); CharSequence cs2 = (CharSequence) self.doAction("getCs2", actionContext); return StringUtils.indexOfDifference(cs1, cs2); }
private String getBranchForRevision(SVNRepository repository, SVNLogEntry logEntry) { // List of paths for this revision @SuppressWarnings("unchecked") Set<String> paths = logEntry.getChangedPaths().keySet(); // Finds the common path among all those paths String commonPath = null; for (String path : paths) { if (commonPath == null) { commonPath = path; } else { int diff = StringUtils.indexOfDifference(commonPath, path); commonPath = StringUtils.left(commonPath, diff); } } // Gets the branch for this path if (commonPath != null) { return extractBranch(repository, commonPath); } else { // No path in the revision: no branch! return null; } }
indexOfDifference = StringUtils.indexOfDifference(reference, alt); if (indexOfDifference < 0) {
int diffIndex = StringUtils.indexOfDifference(initialText, annotationText); String expected = initialText.substring(diffIndex, Math.min(initialText.length(), diffIndex + 20));
int diffIndex = StringUtils.indexOfDifference(initialText, annotationText); String expected = initialText.substring(diffIndex, Math.min(initialText.length(), diffIndex + 20));
braket = ']'; case SE: indexOfDifference = StringUtils.indexOfDifference(reference, alternate); if (alternate.startsWith(reference)) { newStart = start + indexOfDifference;