Renamed StringUtils.differenceAt() to StringUtils.indexOfDifference()

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137645 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary D. Gregory 2003-08-21 22:13:24 +00:00
parent fac4f8d2d6
commit 70075bdf4a
2 changed files with 21 additions and 21 deletions

View File

@ -145,7 +145,7 @@
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
* @author Phil Steitz
* @since 1.0
* @version $Id: StringUtils.java,v 1.104 2003/08/21 05:57:21 ggregory Exp $
* @version $Id: StringUtils.java,v 1.105 2003/08/21 22:13:24 ggregory Exp $
*/
public class StringUtils {
// Performance testing notes (JDK 1.4, Jul03, scolebourne)
@ -4143,7 +4143,7 @@ public static String difference(String str1, String str2) {
if (str2 == null) {
return str1;
}
int at = differenceAt(str1, str2);
int at = indexOfDifference(str1, str2);
if (at == -1) {
return EMPTY;
}
@ -4158,14 +4158,14 @@ public static String difference(String str1, String str2) {
* <code>differenceAt("i am a machine", "i am a robot") -> 7</code></p>
*
* <pre>
* StringUtils.differenceAt(null, null) = -1
* StringUtils.differenceAt("", "") = -1
* StringUtils.differenceAt("", "abc") = 0
* StringUtils.differenceAt("abc", "") = 0
* StringUtils.differenceAt("abc", "abc") = -1
* StringUtils.differenceAt("ab", "abxyz") = 2
* StringUtils.differenceAt("abcde", "abxyz") = 2
* StringUtils.differenceAt("abcde", "xyz") = 0
* StringUtils.indexOfDifference(null, null) = -1
* StringUtils.indexOfDifference("", "") = -1
* StringUtils.indexOfDifference("", "abc") = 0
* StringUtils.indexOfDifference("abc", "") = 0
* StringUtils.indexOfDifference("abc", "abc") = -1
* StringUtils.indexOfDifference("ab", "abxyz") = 2
* StringUtils.indexOfDifference("abcde", "abxyz") = 2
* StringUtils.indexOfDifference("abcde", "xyz") = 0
* </pre>
*
* @param str1 the first String, may be null
@ -4173,7 +4173,7 @@ public static String difference(String str1, String str2) {
* @return the index where str2 and str1 begin to differ; -1 if they are equal
* @since 2.0
*/
public static int differenceAt(String str1, String str2) {
public static int indexOfDifference(String str1, String str2) {
if (str1 == str2) {
return -1;
}

View File

@ -75,7 +75,7 @@
* @author <a href="hps@intermeta.de">Henning P. Schmiedehausen</a>
* @author Phil Steitz
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
* @version $Id: StringUtilsTest.java,v 1.51 2003/08/18 02:22:25 bayard Exp $
* @version $Id: StringUtilsTest.java,v 1.52 2003/08/21 22:13:24 ggregory Exp $
*/
public class StringUtilsTest extends TestCase {
@ -942,15 +942,15 @@ public void testDifference_StringString() {
}
public void testDifferenceAt_StringString() {
assertEquals(-1, StringUtils.differenceAt(null, null));
assertEquals(0, StringUtils.differenceAt(null, "i am a robot"));
assertEquals(-1, StringUtils.differenceAt("", ""));
assertEquals(0, StringUtils.differenceAt("", "abc"));
assertEquals(0, StringUtils.differenceAt("abc", ""));
assertEquals(0, StringUtils.differenceAt("i am a machine", null));
assertEquals(7, StringUtils.differenceAt("i am a machine", "i am a robot"));
assertEquals(-1, StringUtils.differenceAt("foo", "foo"));
assertEquals(0, StringUtils.differenceAt("i am a robot", "you are a robot"));
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"));
}
//-----------------------------------------------------------------------