Add more javadoc example code
Ensure empty string behaviour documented in example code git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137473 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
91a22bc494
commit
1ea34cbbba
|
@ -142,7 +142,7 @@
|
||||||
* @author Arun Mammen Thomas
|
* @author Arun Mammen Thomas
|
||||||
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
|
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
* @version $Id: StringUtils.java,v 1.72 2003/07/20 14:47:29 scolebourne Exp $
|
* @version $Id: StringUtils.java,v 1.73 2003/07/20 15:29:44 scolebourne Exp $
|
||||||
*/
|
*/
|
||||||
public class StringUtils {
|
public class StringUtils {
|
||||||
// Performance testing notes (JDK 1.4, Jul03, scolebourne)
|
// Performance testing notes (JDK 1.4, Jul03, scolebourne)
|
||||||
|
@ -297,10 +297,10 @@ public static boolean isNotBlank(String str) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.clean(null) = ""
|
* StringUtils.clean(null) = ""
|
||||||
|
* StringUtils.clean("") = ""
|
||||||
* StringUtils.clean("abc") = "abc"
|
* StringUtils.clean("abc") = "abc"
|
||||||
* StringUtils.clean(" abc ") = "abc"
|
* StringUtils.clean(" abc ") = "abc"
|
||||||
* StringUtils.clean(" ") = ""
|
* StringUtils.clean(" ") = ""
|
||||||
* StringUtils.clean("") = ""
|
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @see java.lang.String#trim()
|
* @see java.lang.String#trim()
|
||||||
|
@ -327,10 +327,10 @@ public static String clean(String str) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.trim(null) = null
|
* StringUtils.trim(null) = null
|
||||||
|
* StringUtils.trim("") = ""
|
||||||
|
* StringUtils.trim(" ") = ""
|
||||||
* StringUtils.trim("abc") = "abc"
|
* StringUtils.trim("abc") = "abc"
|
||||||
* StringUtils.trim(" abc ") = "abc"
|
* StringUtils.trim(" abc ") = "abc"
|
||||||
* StringUtils.trim(" ") = ""
|
|
||||||
* StringUtils.trim("") = ""
|
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param str the String to be trimmed, may be null
|
* @param str the String to be trimmed, may be null
|
||||||
|
@ -351,10 +351,10 @@ public static String trim(String str) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.trimToNull(null) = null
|
* StringUtils.trimToNull(null) = null
|
||||||
|
* StringUtils.trimToNull("") = null
|
||||||
|
* StringUtils.trimToNull(" ") = null
|
||||||
* StringUtils.trimToNull("abc") = "abc"
|
* StringUtils.trimToNull("abc") = "abc"
|
||||||
* StringUtils.trimToNull(" abc ") = "abc"
|
* StringUtils.trimToNull(" abc ") = "abc"
|
||||||
* StringUtils.trimToNull(" ") = null
|
|
||||||
* StringUtils.trimToNull("") = null
|
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param str the String to be trimmed, may be null
|
* @param str the String to be trimmed, may be null
|
||||||
|
@ -377,10 +377,10 @@ public static String trimToNull(String str) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.trimToEmpty(null) = ""
|
* StringUtils.trimToEmpty(null) = ""
|
||||||
|
* StringUtils.trimToEmpty("") = ""
|
||||||
|
* StringUtils.trimToEmpty(" ") = ""
|
||||||
* StringUtils.trimToEmpty("abc") = "abc"
|
* StringUtils.trimToEmpty("abc") = "abc"
|
||||||
* StringUtils.trimToEmpty(" abc ") = "abc"
|
* StringUtils.trimToEmpty(" abc ") = "abc"
|
||||||
* StringUtils.trimToEmpty(" ") = ""
|
|
||||||
* StringUtils.trimToEmpty("") = ""
|
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param str the String to be trimmed, may be null
|
* @param str the String to be trimmed, may be null
|
||||||
|
@ -487,6 +487,7 @@ public static String stripToEmpty(String str) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.strip(null, null) = null
|
* StringUtils.strip(null, null) = null
|
||||||
|
* StringUtils.strip("", null) = ""
|
||||||
* StringUtils.strip("abc", null) = "abc"
|
* StringUtils.strip("abc", null) = "abc"
|
||||||
* StringUtils.strip(" abc", null) = "abc"
|
* StringUtils.strip(" abc", null) = "abc"
|
||||||
* StringUtils.strip("abc ", null) = "abc"
|
* StringUtils.strip("abc ", null) = "abc"
|
||||||
|
@ -515,12 +516,14 @@ public static String strip(String str, String stripChars) {
|
||||||
* stripped as defined by {@link Character#isWhitespace(char)}.</p>
|
* stripped as defined by {@link Character#isWhitespace(char)}.</p>
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.strip(null, null) = null
|
* StringUtils.stripStart(null, null) = null
|
||||||
* StringUtils.strip("abc", null) = "abc"
|
* StringUtils.stripStart("", null) = ""
|
||||||
* StringUtils.strip(" abc", null) = "abc"
|
* StringUtils.stripStart("abc", "") = "abc"
|
||||||
* StringUtils.strip("abc ", null) = "abc "
|
* StringUtils.stripStart("abc", null) = "abc"
|
||||||
* StringUtils.strip(" abc ", null) = "abc "
|
* StringUtils.stripStart(" abc", null) = "abc"
|
||||||
* StringUtils.strip("yxabc ", "xyz") = "abc "
|
* StringUtils.stripStart("abc ", null) = "abc "
|
||||||
|
* StringUtils.stripStart(" abc ", null) = "abc "
|
||||||
|
* StringUtils.stripStart("yxabc ", "xyz") = "abc "
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param str the String to remove characters from, may be null
|
* @param str the String to remove characters from, may be null
|
||||||
|
@ -537,6 +540,8 @@ public static String stripStart(String str, String stripChars) {
|
||||||
while ((start != strLen) && Character.isWhitespace(str.charAt(start))) {
|
while ((start != strLen) && Character.isWhitespace(str.charAt(start))) {
|
||||||
start++;
|
start++;
|
||||||
}
|
}
|
||||||
|
} else if (stripChars.length() == 0) {
|
||||||
|
return str;
|
||||||
} else {
|
} else {
|
||||||
while ((start != strLen) && (stripChars.indexOf(str.charAt(start)) != -1)) {
|
while ((start != strLen) && (stripChars.indexOf(str.charAt(start)) != -1)) {
|
||||||
start++;
|
start++;
|
||||||
|
@ -554,12 +559,14 @@ public static String stripStart(String str, String stripChars) {
|
||||||
* stripped as defined by {@link Character#isWhitespace(char)}.</p>
|
* stripped as defined by {@link Character#isWhitespace(char)}.</p>
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.strip(null, null) = null
|
* StringUtils.stripEnd(null, null) = null
|
||||||
* StringUtils.strip("abc", null) = "abc"
|
* StringUtils.stripEnd("", null) = ""
|
||||||
* StringUtils.strip(" abc", null) = " abc"
|
* StringUtils.stripEnd("abc", "") = "abc"
|
||||||
* StringUtils.strip("abc ", null) = "abc"
|
* StringUtils.stripEnd("abc", null) = "abc"
|
||||||
* StringUtils.strip(" abc ", null) = " abc"
|
* StringUtils.stripEnd(" abc", null) = " abc"
|
||||||
* StringUtils.strip(" abcyx", "xyz") = " abc"
|
* StringUtils.stripEnd("abc ", null) = "abc"
|
||||||
|
* StringUtils.stripEnd(" abc ", null) = " abc"
|
||||||
|
* StringUtils.stripEnd(" abcyx", "xyz") = " abc"
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param str the String to remove characters from, may be null
|
* @param str the String to remove characters from, may be null
|
||||||
|
@ -576,6 +583,8 @@ public static String stripEnd(String str, String stripChars) {
|
||||||
while ((end != 0) && Character.isWhitespace(str.charAt(end - 1))) {
|
while ((end != 0) && Character.isWhitespace(str.charAt(end - 1))) {
|
||||||
end--;
|
end--;
|
||||||
}
|
}
|
||||||
|
} else if (stripChars.length() == 0) {
|
||||||
|
return str;
|
||||||
} else {
|
} else {
|
||||||
while ((end != 0) && (stripChars.indexOf(str.charAt(end - 1)) != -1)) {
|
while ((end != 0) && (stripChars.indexOf(str.charAt(end - 1)) != -1)) {
|
||||||
end--;
|
end--;
|
||||||
|
@ -1016,6 +1025,8 @@ public static boolean contains(String str, String searchStr) {
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.indexOfAny(null, null) = -1
|
* StringUtils.indexOfAny(null, null) = -1
|
||||||
* StringUtils.indexOfAny(null, ["ab","cd"]) = -1
|
* StringUtils.indexOfAny(null, ["ab","cd"]) = -1
|
||||||
|
* StringUtils.indexOfAny("", null) = -1
|
||||||
|
* StringUtils.indexOfAny("", ["ab","cd"]) = -1
|
||||||
* StringUtils.indexOfAny("zzabyycdxx", null) = -1
|
* StringUtils.indexOfAny("zzabyycdxx", null) = -1
|
||||||
* StringUtils.indexOfAny("zzabyycdxx", []) = -1
|
* StringUtils.indexOfAny("zzabyycdxx", []) = -1
|
||||||
* StringUtils.indexOfAny("zzabyycdxx", ["ab","cd"]) = 2
|
* StringUtils.indexOfAny("zzabyycdxx", ["ab","cd"]) = 2
|
||||||
|
@ -1065,6 +1076,8 @@ public static int indexOfAny(String str, String[] searchStrs) {
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.lastIndexOfAny(null, null) = -1
|
* StringUtils.lastIndexOfAny(null, null) = -1
|
||||||
* StringUtils.lastIndexOfAny(null, ["ab","cd"]) = -1
|
* StringUtils.lastIndexOfAny(null, ["ab","cd"]) = -1
|
||||||
|
* StringUtils.lastIndexOfAny("", null) = -1
|
||||||
|
* StringUtils.lastIndexOfAny("", ["ab","cd"]) = -1
|
||||||
* StringUtils.lastIndexOfAny("zzabyycdxx", null) = -1
|
* StringUtils.lastIndexOfAny("zzabyycdxx", null) = -1
|
||||||
* StringUtils.lastIndexOfAny("zzabyycdxx", []) = -1
|
* StringUtils.lastIndexOfAny("zzabyycdxx", []) = -1
|
||||||
* StringUtils.lastIndexOfAny("zzabyycdxx", ["ab","cd"]) = 6
|
* StringUtils.lastIndexOfAny("zzabyycdxx", ["ab","cd"]) = 6
|
||||||
|
@ -1270,6 +1283,7 @@ public static boolean containsNone(String str, String invalidChars) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.substring(null, 0) = null
|
* StringUtils.substring(null, 0) = null
|
||||||
|
* StringUtils.substring("", 0) = ""
|
||||||
* StringUtils.substring("abc", 0) = "abc"
|
* StringUtils.substring("abc", 0) = "abc"
|
||||||
* StringUtils.substring("abc", 2) = "c"
|
* StringUtils.substring("abc", 2) = "c"
|
||||||
* StringUtils.substring("abc", 4) = ""
|
* StringUtils.substring("abc", 4) = ""
|
||||||
|
@ -1310,6 +1324,7 @@ public static String substring(String str, int start) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.substring(null, 0, 2) = null
|
* StringUtils.substring(null, 0, 2) = null
|
||||||
|
* StringUtils.substring("", 0, 2) = ""
|
||||||
* StringUtils.substring("abc", 0, 2) = "ab"
|
* StringUtils.substring("abc", 0, 2) = "ab"
|
||||||
* StringUtils.substring("abc", 2, 0) = ""
|
* StringUtils.substring("abc", 2, 0) = ""
|
||||||
* StringUtils.substring("abc", 2, 4) = "c"
|
* StringUtils.substring("abc", 2, 4) = "c"
|
||||||
|
@ -1341,7 +1356,6 @@ public static String substring(String str, int start, int end) {
|
||||||
|
|
||||||
// check length next
|
// check length next
|
||||||
if (end > str.length()) {
|
if (end > str.length()) {
|
||||||
// check this works.
|
|
||||||
end = str.length();
|
end = str.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1372,6 +1386,7 @@ public static String substring(String str, int start, int end) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.left(null, 0) = null
|
* StringUtils.left(null, 0) = null
|
||||||
|
* StringUtils.left("", 2) = ""
|
||||||
* StringUtils.left("abc", 0) = ""
|
* StringUtils.left("abc", 0) = ""
|
||||||
* StringUtils.left("abc", 2) = "ab"
|
* StringUtils.left("abc", 2) = "ab"
|
||||||
* StringUtils.left("abc", 4) = "abc"
|
* StringUtils.left("abc", 4) = "abc"
|
||||||
|
@ -1403,6 +1418,7 @@ public static String left(String str, int len) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.right(null, 0) = null
|
* StringUtils.right(null, 0) = null
|
||||||
|
* StringUtils.right("", 2) = ""
|
||||||
* StringUtils.right("abc", 0) = ""
|
* StringUtils.right("abc", 0) = ""
|
||||||
* StringUtils.right("abc", 2) = "bc"
|
* StringUtils.right("abc", 2) = "bc"
|
||||||
* StringUtils.right("abc", 4) = "abc"
|
* StringUtils.right("abc", 4) = "abc"
|
||||||
|
@ -1434,6 +1450,7 @@ public static String right(String str, int len) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.mid(null, 0, 0) = null
|
* StringUtils.mid(null, 0, 0) = null
|
||||||
|
* StringUtils.mid("", 0, 4) = ""
|
||||||
* StringUtils.mid("abc", 0, 2) = "ab"
|
* StringUtils.mid("abc", 0, 2) = "ab"
|
||||||
* StringUtils.mid("abc", 0, 4) = "abc"
|
* StringUtils.mid("abc", 0, 4) = "abc"
|
||||||
* StringUtils.mid("abc", 2, 4) = "c"
|
* StringUtils.mid("abc", 2, 4) = "c"
|
||||||
|
@ -1829,6 +1846,7 @@ public static String join(Iterator iterator, String separator) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.deleteSpaces(null) = null
|
* StringUtils.deleteSpaces(null) = null
|
||||||
|
* StringUtils.deleteSpaces("") = ""
|
||||||
* StringUtils.deleteSpaces("abc") = "abc"
|
* StringUtils.deleteSpaces("abc") = "abc"
|
||||||
* StringUtils.deleteSpaces(" \t abc \n ") = "abc"
|
* StringUtils.deleteSpaces(" \t abc \n ") = "abc"
|
||||||
* StringUtils.deleteSpaces("ab c") = "abc"
|
* StringUtils.deleteSpaces("ab c") = "abc"
|
||||||
|
@ -1855,9 +1873,10 @@ public static String deleteSpaces(String str) {
|
||||||
* {@link Character#isWhitespace(char)}.</p>
|
* {@link Character#isWhitespace(char)}.</p>
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.deleteWhitespace(null) = null
|
* StringUtils.deleteWhitespace(null) = null
|
||||||
* StringUtils.deleteWhitespace("abc") = "abc"
|
* StringUtils.deleteWhitespace("") = ""
|
||||||
* StringUtils.deleteWhitespace(" abc ") = "abc"
|
* StringUtils.deleteWhitespace("abc") = "abc"
|
||||||
|
* StringUtils.deleteWhitespace(" ab c ") = "abc"
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param str the String to delete whitespace from, may be null
|
* @param str the String to delete whitespace from, may be null
|
||||||
|
@ -1887,6 +1906,7 @@ public static String deleteWhitespace(String str) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.replaceOnce(null, null, null) = null
|
* StringUtils.replaceOnce(null, null, null) = null
|
||||||
|
* StringUtils.replaceOnce("", null, null) = ""
|
||||||
* StringUtils.replaceOnce("aba", null, null) = "aba"
|
* StringUtils.replaceOnce("aba", null, null) = "aba"
|
||||||
* StringUtils.replaceOnce("aba", null, null) = "aba"
|
* StringUtils.replaceOnce("aba", null, null) = "aba"
|
||||||
* StringUtils.replaceOnce("aba", "a", null) = "aba"
|
* StringUtils.replaceOnce("aba", "a", null) = "aba"
|
||||||
|
@ -1912,6 +1932,7 @@ public static String replaceOnce(String text, String repl, String with) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.replace(null, null, null) = null
|
* StringUtils.replace(null, null, null) = null
|
||||||
|
* StringUtils.replace("", null, null) = ""
|
||||||
* StringUtils.replace("aba", null, null) = "aba"
|
* StringUtils.replace("aba", null, null) = "aba"
|
||||||
* StringUtils.replace("aba", null, null) = "aba"
|
* StringUtils.replace("aba", null, null) = "aba"
|
||||||
* StringUtils.replace("aba", "a", null) = "aba"
|
* StringUtils.replace("aba", "a", null) = "aba"
|
||||||
|
@ -1938,6 +1959,7 @@ public static String replace(String text, String repl, String with) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.replace(null, null, null, 1) = null
|
* StringUtils.replace(null, null, null, 1) = null
|
||||||
|
* StringUtils.replace("", null, null, 1) = ""
|
||||||
* StringUtils.replace("abaa", null, null, 1) = "abaa"
|
* StringUtils.replace("abaa", null, null, 1) = "abaa"
|
||||||
* StringUtils.replace("abaa", null, null, 1) = "abaa"
|
* StringUtils.replace("abaa", null, null, 1) = "abaa"
|
||||||
* StringUtils.replace("abaa", "a", null, 1) = "abaa"
|
* StringUtils.replace("abaa", "a", null, 1) = "abaa"
|
||||||
|
@ -1979,6 +2001,7 @@ public static String replace(String text, String repl, String with, int max) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.overlayString(null, null, 2, 4) = null
|
* StringUtils.overlayString(null, null, 2, 4) = null
|
||||||
|
* StringUtils.overlayString("", "abc", 0, 0) = "abc"
|
||||||
* StringUtils.overlayString("abcdef", null, 2, 4) = "abef"
|
* StringUtils.overlayString("abcdef", null, 2, 4) = "abef"
|
||||||
* StringUtils.overlayString("abcdef", "", 2, 4) = "abef"
|
* StringUtils.overlayString("abcdef", "", 2, 4) = "abef"
|
||||||
* StringUtils.overlayString("abcdef", "zzzz", 2, 4) = "abzzzzef"
|
* StringUtils.overlayString("abcdef", "zzzz", 2, 4) = "abzzzzef"
|
||||||
|
@ -2465,6 +2488,7 @@ private static String padding(int repeat, char padChar) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.rightPad(null, 1) = null
|
* StringUtils.rightPad(null, 1) = null
|
||||||
|
* StringUtils.rightPad("", 3) = " "
|
||||||
* StringUtils.rightPad("bat", 3) = "bat"
|
* StringUtils.rightPad("bat", 3) = "bat"
|
||||||
* StringUtils.rightPad("bat", 5) = "bat "
|
* StringUtils.rightPad("bat", 5) = "bat "
|
||||||
* StringUtils.rightPad("bat", 1) = "bat"
|
* StringUtils.rightPad("bat", 1) = "bat"
|
||||||
|
@ -2487,6 +2511,7 @@ public static String rightPad(String str, int size) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.rightPad(null, 1, 'z') = null
|
* StringUtils.rightPad(null, 1, 'z') = null
|
||||||
|
* StringUtils.rightPad("", 3, 'z') = "zzz"
|
||||||
* StringUtils.rightPad("bat", 3, 'z') = "bat"
|
* StringUtils.rightPad("bat", 3, 'z') = "bat"
|
||||||
* StringUtils.rightPad("bat", 5, 'z') = "batzz"
|
* StringUtils.rightPad("bat", 5, 'z') = "batzz"
|
||||||
* StringUtils.rightPad("bat", 1, 'z') = "bat"
|
* StringUtils.rightPad("bat", 1, 'z') = "bat"
|
||||||
|
@ -2520,6 +2545,7 @@ public static String rightPad(String str, int size, char padChar) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.rightPad(null, 1, "yz") = null
|
* StringUtils.rightPad(null, 1, "yz") = null
|
||||||
|
* StringUtils.rightPad("", 3, "z") = "zzz"
|
||||||
* StringUtils.rightPad("bat", 3, "yz") = "bat"
|
* StringUtils.rightPad("bat", 3, "yz") = "bat"
|
||||||
* StringUtils.rightPad("bat", 5, "yz") = "batyz"
|
* StringUtils.rightPad("bat", 5, "yz") = "batyz"
|
||||||
* StringUtils.rightPad("bat", 8, "yz") = "batyzyzy"
|
* StringUtils.rightPad("bat", 8, "yz") = "batyzyzy"
|
||||||
|
@ -2575,6 +2601,7 @@ public static String rightPad(String str, int size, String padStr) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.leftPad(null, 1) = null
|
* StringUtils.leftPad(null, 1) = null
|
||||||
|
* StringUtils.leftPad("", 3) = " "
|
||||||
* StringUtils.leftPad("bat", 3) = "bat"
|
* StringUtils.leftPad("bat", 3) = "bat"
|
||||||
* StringUtils.leftPad("bat", 5) = " bat"
|
* StringUtils.leftPad("bat", 5) = " bat"
|
||||||
* StringUtils.leftPad("bat", 1) = "bat"
|
* StringUtils.leftPad("bat", 1) = "bat"
|
||||||
|
@ -2597,6 +2624,7 @@ public static String leftPad(String str, int size) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.leftPad(null, 1, 'z') = null
|
* StringUtils.leftPad(null, 1, 'z') = null
|
||||||
|
* StringUtils.leftPad("", 3, 'z') = "zzz"
|
||||||
* StringUtils.leftPad("bat", 3, 'z') = "bat"
|
* StringUtils.leftPad("bat", 3, 'z') = "bat"
|
||||||
* StringUtils.leftPad("bat", 5, 'z') = "zzbat"
|
* StringUtils.leftPad("bat", 5, 'z') = "zzbat"
|
||||||
* StringUtils.leftPad("bat", 1, 'z') = "bat"
|
* StringUtils.leftPad("bat", 1, 'z') = "bat"
|
||||||
|
@ -2630,6 +2658,7 @@ public static String leftPad(String str, int size, char padChar) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.leftPad(null, 1, "yz") = null
|
* StringUtils.leftPad(null, 1, "yz") = null
|
||||||
|
* StringUtils.leftPad("", 3, "z") = "zzz"
|
||||||
* StringUtils.leftPad("bat", 3, "yz") = "bat"
|
* StringUtils.leftPad("bat", 3, "yz") = "bat"
|
||||||
* StringUtils.leftPad("bat", 5, "yz") = "yzbat"
|
* StringUtils.leftPad("bat", 5, "yz") = "yzbat"
|
||||||
* StringUtils.leftPad("bat", 8, "yz") = "yzyzybat"
|
* StringUtils.leftPad("bat", 8, "yz") = "yzyzybat"
|
||||||
|
@ -2694,8 +2723,8 @@ public static String leftPad(String str, int size, String padStr) {
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.center(null, -1) = null
|
* StringUtils.center(null, -1) = null
|
||||||
* StringUtils.center(null, 4) = null
|
* StringUtils.center(null, 4) = null
|
||||||
* StringUtils.center("ab", -1) = "ab"
|
|
||||||
* StringUtils.center("", 4) = " "
|
* StringUtils.center("", 4) = " "
|
||||||
|
* StringUtils.center("ab", -1) = "ab"
|
||||||
* StringUtils.center("ab", 4) = " ab "
|
* StringUtils.center("ab", 4) = " ab "
|
||||||
* StringUtils.center("abcd", 2) = "abcd"
|
* StringUtils.center("abcd", 2) = "abcd"
|
||||||
* StringUtils.center("a", 4) = " a "
|
* StringUtils.center("a", 4) = " a "
|
||||||
|
@ -2719,9 +2748,9 @@ public static String center(String str, int size) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.center(null, -1, ' ') = null
|
* StringUtils.center(null, -1, ' ') = null
|
||||||
* StringUtils.center("ab", -1, ' ') = "ab"
|
|
||||||
* StringUtils.center(null, 4, ' ') = null
|
* StringUtils.center(null, 4, ' ') = null
|
||||||
* StringUtils.center("", 4, ' ') = " "
|
* StringUtils.center("", 4, ' ') = " "
|
||||||
|
* StringUtils.center("ab", -1, ' ') = "ab"
|
||||||
* StringUtils.center("ab", 4, ' ') = " ab"
|
* StringUtils.center("ab", 4, ' ') = " ab"
|
||||||
* StringUtils.center("abcd", 2, ' ') = "abcd"
|
* StringUtils.center("abcd", 2, ' ') = "abcd"
|
||||||
* StringUtils.center("a", 4, ' ') = " a "
|
* StringUtils.center("a", 4, ' ') = " a "
|
||||||
|
@ -2757,9 +2786,9 @@ public static String center(String str, int size, char padChar) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.center(null, -1, " ") = null
|
* StringUtils.center(null, -1, " ") = null
|
||||||
* StringUtils.center("ab", -1, " ") = "ab"
|
|
||||||
* StringUtils.center(null, 4, " ") = null
|
* StringUtils.center(null, 4, " ") = null
|
||||||
* StringUtils.center("", 4, " ") = " "
|
* StringUtils.center("", 4, " ") = " "
|
||||||
|
* StringUtils.center("ab", -1, " ") = "ab"
|
||||||
* StringUtils.center("ab", 4, " ") = " ab"
|
* StringUtils.center("ab", 4, " ") = " ab"
|
||||||
* StringUtils.center("abcd", 2, " ") = "abcd"
|
* StringUtils.center("abcd", 2, " ") = "abcd"
|
||||||
* StringUtils.center("a", 4, " ") = " a "
|
* StringUtils.center("a", 4, " ") = " a "
|
||||||
|
@ -2802,6 +2831,7 @@ public static String center(String str, int size, String padStr) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.upperCase(null) = null
|
* StringUtils.upperCase(null) = null
|
||||||
|
* StringUtils.upperCase("") = ""
|
||||||
* StringUtils.upperCase("aBc") = "ABC"
|
* StringUtils.upperCase("aBc") = "ABC"
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -2822,6 +2852,7 @@ public static String upperCase(String str) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.lowerCase(null) = null
|
* StringUtils.lowerCase(null) = null
|
||||||
|
* StringUtils.lowerCase("") = ""
|
||||||
* StringUtils.lowerCase("aBc") = "abc"
|
* StringUtils.lowerCase("aBc") = "abc"
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -2843,6 +2874,7 @@ public static String lowerCase(String str) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.capitalise(null) = null
|
* StringUtils.capitalise(null) = null
|
||||||
|
* StringUtils.capitalise("") = ""
|
||||||
* StringUtils.capitalise("cat") = "Cat"
|
* StringUtils.capitalise("cat") = "Cat"
|
||||||
* StringUtils.capitalise("cAt") = "CAt"
|
* StringUtils.capitalise("cAt") = "CAt"
|
||||||
* </pre>
|
* </pre>
|
||||||
|
@ -2869,6 +2901,7 @@ public static String capitalise(String str) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.uncapitalise(null) = null
|
* StringUtils.uncapitalise(null) = null
|
||||||
|
* StringUtils.uncapitalise("") = ""
|
||||||
* StringUtils.uncapitalise("Cat") = "cat"
|
* StringUtils.uncapitalise("Cat") = "cat"
|
||||||
* StringUtils.uncapitalise("CAT") = "cAT"
|
* StringUtils.uncapitalise("CAT") = "cAT"
|
||||||
* </pre>
|
* </pre>
|
||||||
|
@ -2902,6 +2935,7 @@ public static String uncapitalise(String str) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.swapCase(null) = null
|
* StringUtils.swapCase(null) = null
|
||||||
|
* StringUtils.swapCase("") = ""
|
||||||
* StringUtils.swapCase("The dog has a BONE") = "tHE DOG HAS A bone"
|
* StringUtils.swapCase("The dog has a BONE") = "tHE DOG HAS A bone"
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -3028,6 +3062,8 @@ public static String uncapitaliseAllWords(String str) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.getNestedString(null, "tag") = null
|
* StringUtils.getNestedString(null, "tag") = null
|
||||||
|
* StringUtils.getNestedString("", "") = ""
|
||||||
|
* StringUtils.getNestedString("", "tag") = null
|
||||||
* StringUtils.getNestedString("tagabctag", null) = null
|
* StringUtils.getNestedString("tagabctag", null) = null
|
||||||
* StringUtils.getNestedString("tagabctag", "") = ""
|
* StringUtils.getNestedString("tagabctag", "") = ""
|
||||||
* StringUtils.getNestedString("tagabctag", "tag") = "abc"
|
* StringUtils.getNestedString("tagabctag", "tag") = "abc"
|
||||||
|
@ -3051,6 +3087,9 @@ public static String getNestedString(String str, String tag) {
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* StringUtils.getNestedString(null, "y", "z") = null
|
* StringUtils.getNestedString(null, "y", "z") = null
|
||||||
|
* StringUtils.getNestedString("", "", "") = ""
|
||||||
|
* StringUtils.getNestedString("", "", "tag") = null
|
||||||
|
* StringUtils.getNestedString("", "tag", "tag") = null
|
||||||
* StringUtils.getNestedString("yabcz", null, null) = null
|
* StringUtils.getNestedString("yabcz", null, null) = null
|
||||||
* StringUtils.getNestedString("yabcz", "", "") = ""
|
* StringUtils.getNestedString("yabcz", "", "") = ""
|
||||||
* StringUtils.getNestedString("yabcz", "y", "z") = "abc"
|
* StringUtils.getNestedString("yabcz", "y", "z") = "abc"
|
||||||
|
@ -3082,8 +3121,22 @@ public static String getNestedString(String str, String open, String close) {
|
||||||
/**
|
/**
|
||||||
* <p>How many times is the substring in the larger String.</p>
|
* <p>How many times is the substring in the larger String.</p>
|
||||||
*
|
*
|
||||||
* <p><code>null</code> returns <code>0</code>.</p>
|
* <p>A <code>null</code> String input returns <code>0</code>.</p>
|
||||||
*
|
*
|
||||||
|
* <pre>
|
||||||
|
* StringUtils.countMatches(null, null) = 0
|
||||||
|
* StringUtils.countMatches(null, "") = 0
|
||||||
|
* StringUtils.countMatches(null, "a") = 0
|
||||||
|
* StringUtils.countMatches("", null) = 0
|
||||||
|
* StringUtils.countMatches("", "") = 0
|
||||||
|
* StringUtils.countMatches("", "a") = 0
|
||||||
|
* StringUtils.countMatches("abba", null) = 0
|
||||||
|
* StringUtils.countMatches("abba", "") = 0
|
||||||
|
* StringUtils.countMatches("abba", "a") = 2
|
||||||
|
* StringUtils.countMatches("abba", "ab") = 1
|
||||||
|
* StringUtils.countMatches("abba", "xxx") = 0
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
* @param str the String to check, may be null
|
* @param str the String to check, may be null
|
||||||
* @param sub the substring to count, may be null
|
* @param sub the substring to count, may be null
|
||||||
* @return the number of occurances, 0 if either String is <code>null</code>
|
* @return the number of occurances, 0 if either String is <code>null</code>
|
||||||
|
@ -3110,6 +3163,15 @@ public static int countMatches(String str, String sub) {
|
||||||
* <p><code>null</code> will return <code>false</code>.
|
* <p><code>null</code> will return <code>false</code>.
|
||||||
* An empty String ("") will return <code>true</code>.</p>
|
* An empty String ("") will return <code>true</code>.</p>
|
||||||
*
|
*
|
||||||
|
* <pre>
|
||||||
|
* StringUtils.isAlpha(null) = false
|
||||||
|
* StringUtils.isAlpha("") = true
|
||||||
|
* StringUtils.isAlpha(" ") = false
|
||||||
|
* StringUtils.isAlpha("abc") = true
|
||||||
|
* StringUtils.isAlpha("ab2c") = false
|
||||||
|
* StringUtils.isAlpha("ab-c") = false
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
* @param str the String to check, may be null
|
* @param str the String to check, may be null
|
||||||
* @return <code>true</code> if only contains letters, and is non-null
|
* @return <code>true</code> if only contains letters, and is non-null
|
||||||
*/
|
*/
|
||||||
|
@ -3126,28 +3188,6 @@ public static boolean isAlpha(String str) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>Checks if the String contains only whitespace.</p>
|
|
||||||
*
|
|
||||||
* <p><code>null</code> will return <code>false</code>.
|
|
||||||
* An empty String ("") will return <code>true</code>.</p>
|
|
||||||
*
|
|
||||||
* @param str the String to check, may be null
|
|
||||||
* @return <code>true</code> if only contains whitespace, and is non-null
|
|
||||||
*/
|
|
||||||
public static boolean isWhitespace(String str) {
|
|
||||||
if (str == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int sz = str.length();
|
|
||||||
for (int i = 0; i < sz; i++) {
|
|
||||||
if ((Character.isWhitespace(str.charAt(i)) == false) ) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Checks if the String contains only unicode letters and
|
* <p>Checks if the String contains only unicode letters and
|
||||||
* space (' ').</p>
|
* space (' ').</p>
|
||||||
|
@ -3155,6 +3195,16 @@ public static boolean isWhitespace(String str) {
|
||||||
* <p><code>null</code> will return <code>false</code>
|
* <p><code>null</code> will return <code>false</code>
|
||||||
* An empty String ("") will return <code>true</code>.</p>
|
* An empty String ("") will return <code>true</code>.</p>
|
||||||
*
|
*
|
||||||
|
* <pre>
|
||||||
|
* StringUtils.isAlphaSpace(null) = false
|
||||||
|
* StringUtils.isAlphaSpace("") = true
|
||||||
|
* StringUtils.isAlphaSpace(" ") = true
|
||||||
|
* StringUtils.isAlphaSpace("abc") = true
|
||||||
|
* StringUtils.isAlphaSpace("ab c") = true
|
||||||
|
* StringUtils.isAlphaSpace("ab2c") = false
|
||||||
|
* StringUtils.isAlphaSpace("ab-c") = false
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
* @param str the String to check, may be null
|
* @param str the String to check, may be null
|
||||||
* @return <code>true</code> if only contains letters and space,
|
* @return <code>true</code> if only contains letters and space,
|
||||||
* and is non-null
|
* and is non-null
|
||||||
|
@ -3179,6 +3229,16 @@ public static boolean isAlphaSpace(String str) {
|
||||||
* <p><code>null</code> will return <code>false</code>.
|
* <p><code>null</code> will return <code>false</code>.
|
||||||
* An empty String ("") will return <code>true</code>.</p>
|
* An empty String ("") will return <code>true</code>.</p>
|
||||||
*
|
*
|
||||||
|
* <pre>
|
||||||
|
* StringUtils.isAlphanumeric(null) = false
|
||||||
|
* StringUtils.isAlphanumeric("") = true
|
||||||
|
* StringUtils.isAlphanumeric(" ") = false
|
||||||
|
* StringUtils.isAlphanumeric("abc") = true
|
||||||
|
* StringUtils.isAlphanumeric("ab c") = false
|
||||||
|
* StringUtils.isAlphanumeric("ab2c") = true
|
||||||
|
* StringUtils.isAlphanumeric("ab-c") = false
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
* @param str the String to check, may be null
|
* @param str the String to check, may be null
|
||||||
* @return <code>true</code> if only contains letters or digits,
|
* @return <code>true</code> if only contains letters or digits,
|
||||||
* and is non-null
|
* and is non-null
|
||||||
|
@ -3203,6 +3263,16 @@ public static boolean isAlphanumeric(String str) {
|
||||||
* <p><code>null</code> will return <code>false</code>.
|
* <p><code>null</code> will return <code>false</code>.
|
||||||
* An empty String ("") will return <code>true</code>.</p>
|
* An empty String ("") will return <code>true</code>.</p>
|
||||||
*
|
*
|
||||||
|
* <pre>
|
||||||
|
* StringUtils.isAlphanumeric(null) = false
|
||||||
|
* StringUtils.isAlphanumeric("") = true
|
||||||
|
* StringUtils.isAlphanumeric(" ") = true
|
||||||
|
* StringUtils.isAlphanumeric("abc") = true
|
||||||
|
* StringUtils.isAlphanumeric("ab c") = true
|
||||||
|
* StringUtils.isAlphanumeric("ab2c") = true
|
||||||
|
* StringUtils.isAlphanumeric("ab-c") = false
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
* @param str the String to check, may be null
|
* @param str the String to check, may be null
|
||||||
* @return <code>true</code> if only contains letters, digits or space,
|
* @return <code>true</code> if only contains letters, digits or space,
|
||||||
* and is non-null
|
* and is non-null
|
||||||
|
@ -3222,11 +3292,23 @@ public static boolean isAlphanumericSpace(String str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Checks if the String contains only unicode digits.</p>
|
* <p>Checks if the String contains only unicode digits.
|
||||||
|
* A decimal point is not a unicode digit and returns false.</p>
|
||||||
*
|
*
|
||||||
* <p><code>null</code> will return <code>false</code>.
|
* <p><code>null</code> will return <code>false</code>.
|
||||||
* An empty String ("") will return <code>true</code>.</p>
|
* An empty String ("") will return <code>true</code>.</p>
|
||||||
*
|
*
|
||||||
|
* <pre>
|
||||||
|
* StringUtils.isNumeric(null) = false
|
||||||
|
* StringUtils.isNumeric("") = true
|
||||||
|
* StringUtils.isNumeric(" ") = false
|
||||||
|
* StringUtils.isNumeric("123") = true
|
||||||
|
* StringUtils.isNumeric("12 3") = false
|
||||||
|
* StringUtils.isNumeric("ab2c") = false
|
||||||
|
* StringUtils.isNumeric("12-3") = false
|
||||||
|
* StringUtils.isNumeric("12.3") = false
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
* @param str the String to check, may be null
|
* @param str the String to check, may be null
|
||||||
* @return <code>true</code> if only contains digits, and is non-null
|
* @return <code>true</code> if only contains digits, and is non-null
|
||||||
*/
|
*/
|
||||||
|
@ -3245,11 +3327,23 @@ public static boolean isNumeric(String str) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Checks if the String contains only unicode digits or space
|
* <p>Checks if the String contains only unicode digits or space
|
||||||
* (<code>' '</code>).</p>
|
* (<code>' '</code>).
|
||||||
|
* A decimal point is not a unicode digit and returns false.</p>
|
||||||
*
|
*
|
||||||
* <p><code>null</code> will return <code>false</code>.
|
* <p><code>null</code> will return <code>false</code>.
|
||||||
* An empty String ("") will return <code>true</code>.</p>
|
* An empty String ("") will return <code>true</code>.</p>
|
||||||
*
|
*
|
||||||
|
* <pre>
|
||||||
|
* StringUtils.isNumeric(null) = false
|
||||||
|
* StringUtils.isNumeric("") = true
|
||||||
|
* StringUtils.isNumeric(" ") = true
|
||||||
|
* StringUtils.isNumeric("123") = true
|
||||||
|
* StringUtils.isNumeric("12 3") = true
|
||||||
|
* StringUtils.isNumeric("ab2c") = false
|
||||||
|
* StringUtils.isNumeric("12-3") = false
|
||||||
|
* StringUtils.isNumeric("12.3") = false
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
* @param str the String to check, may be null
|
* @param str the String to check, may be null
|
||||||
* @return <code>true</code> if only contains digits or space,
|
* @return <code>true</code> if only contains digits or space,
|
||||||
* and is non-null
|
* and is non-null
|
||||||
|
@ -3268,6 +3362,37 @@ public static boolean isNumericSpace(String str) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Checks if the String contains only whitespace.</p>
|
||||||
|
*
|
||||||
|
* <p><code>null</code> will return <code>false</code>.
|
||||||
|
* An empty String ("") will return <code>true</code>.</p>
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* StringUtils.isWhitespace(null) = false
|
||||||
|
* StringUtils.isWhitespace("") = true
|
||||||
|
* StringUtils.isWhitespace(" ") = true
|
||||||
|
* StringUtils.isWhitespace("abc") = false
|
||||||
|
* StringUtils.isWhitespace("ab2c") = false
|
||||||
|
* StringUtils.isWhitespace("ab-c") = false
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param str the String to check, may be null
|
||||||
|
* @return <code>true</code> if only contains whitespace, and is non-null
|
||||||
|
*/
|
||||||
|
public static boolean isWhitespace(String str) {
|
||||||
|
if (str == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int sz = str.length();
|
||||||
|
for (int i = 0; i < sz; i++) {
|
||||||
|
if ((Character.isWhitespace(str.charAt(i)) == false) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Defaults
|
// Defaults
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a>
|
* @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a>
|
||||||
* @author <a href="mailto:ridesmet@users.sourceforge.net">Ringo De Smet</a>
|
* @author <a href="mailto:ridesmet@users.sourceforge.net">Ringo De Smet</a>
|
||||||
* @version $Id: StringUtilsSubstringTest.java,v 1.5 2003/07/18 02:06:23 scolebourne Exp $
|
* @version $Id: StringUtilsSubstringTest.java,v 1.6 2003/07/20 15:29:44 scolebourne Exp $
|
||||||
*/
|
*/
|
||||||
public class StringUtilsSubstringTest extends TestCase {
|
public class StringUtilsSubstringTest extends TestCase {
|
||||||
private static final String FOO = "foo";
|
private static final String FOO = "foo";
|
||||||
|
@ -207,17 +207,21 @@ public void testCountMatches() {
|
||||||
StringUtils.countMatches("oooooooooooo", "ooo"));
|
StringUtils.countMatches("oooooooooooo", "ooo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetNestedString() {
|
public void testGetNestedString_StringString() {
|
||||||
assertEquals(null, StringUtils.getNestedString(null, "tag"));
|
assertEquals(null, StringUtils.getNestedString(null, "tag"));
|
||||||
|
assertEquals("", StringUtils.getNestedString("", ""));
|
||||||
|
assertEquals(null, StringUtils.getNestedString("", "abc"));
|
||||||
|
assertEquals("", StringUtils.getNestedString(" ", " "));
|
||||||
assertEquals(null, StringUtils.getNestedString("abc", null));
|
assertEquals(null, StringUtils.getNestedString("abc", null));
|
||||||
assertEquals("", StringUtils.getNestedString("abc", ""));
|
assertEquals("", StringUtils.getNestedString("abc", ""));
|
||||||
assertEquals(null, StringUtils.getNestedString("abc", "a"));
|
assertEquals(null, StringUtils.getNestedString("abc", "a"));
|
||||||
assertEquals("bc", StringUtils.getNestedString("abca", "a"));
|
assertEquals("bc", StringUtils.getNestedString("abca", "a"));
|
||||||
assertEquals("bc", StringUtils.getNestedString("abcabca", "a"));
|
assertEquals("bc", StringUtils.getNestedString("abcabca", "a"));
|
||||||
assertEquals("", StringUtils.getNestedString("", ""));
|
|
||||||
assertEquals("", StringUtils.getNestedString(" ", " "));
|
|
||||||
assertEquals("bar", StringUtils.getNestedString("\nbar\n", "\n"));
|
assertEquals("bar", StringUtils.getNestedString("\nbar\n", "\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGetNestedString_StringStringString() {
|
||||||
|
assertEquals(null, StringUtils.getNestedString(null, "", ""));
|
||||||
assertEquals("", StringUtils.getNestedString("", "", ""));
|
assertEquals("", StringUtils.getNestedString("", "", ""));
|
||||||
assertEquals("", StringUtils.getNestedString(" ", " ", " "));
|
assertEquals("", StringUtils.getNestedString(" ", " ", " "));
|
||||||
assertEquals("bar", StringUtils.getNestedString("<foo>bar</foo>", "<foo>", "</foo>") );
|
assertEquals("bar", StringUtils.getNestedString("<foo>bar</foo>", "<foo>", "</foo>") );
|
||||||
|
|
Loading…
Reference in New Issue