From a705f50c7e9bf8ed31232de69f5d51b89bbaa76d Mon Sep 17 00:00:00 2001
From: Henri Yandell null
if null String input
* @since 2.4
*/
- private static String[] splitByWholeSeparatorWorker(String str, String separator, int max, boolean preserveAllTokens) {
+ private static String[] splitByWholeSeparatorWorker(String str, String separator, int max,
+ boolean preserveAllTokens)
+ {
if (str == null) {
return null;
}
@@ -3566,20 +3568,20 @@ public static String replaceEach(String text, String[] searchList, String[] repl
*
- * StringUtils.replaceEach(null, *, *, *) = null - * StringUtils.replaceEach("", *, *, *) = "" + * StringUtils.replaceEach(null, *, *, *) = null + * StringUtils.replaceEach("", *, *, *) = "" * StringUtils.replaceEach("aba", null, null, *) = "aba" * StringUtils.replaceEach("aba", new String[0], null, *) = "aba" * StringUtils.replaceEach("aba", null, new String[0], *) = "aba" - * StringUtils.replaceEach("aba", new String[]{"a"}, null, *) = "aba" - * StringUtils.replaceEach("aba", new String[]{"a"}, new String[]{""}, *) = "b" - * StringUtils.replaceEach("aba", new String[]{null}, new String[]{"a"}, *) = "aba" - * StringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"w", "t"}, *) = "wcte" + * StringUtils.replaceEach("aba", new String[]{"a"}, null, *) = "aba" + * StringUtils.replaceEach("aba", new String[]{"a"}, new String[]{""}, *) = "b" + * StringUtils.replaceEach("aba", new String[]{null}, new String[]{"a"}, *) = "aba" + * StringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"w", "t"}, *) = "wcte" * (example of how it repeats) - * StringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"d", "t"}, false) = "dcte" - * StringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"d", "t"}, true) = "tcte" - * StringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"d", "ab"}, true) = IllegalArgumentException - * StringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"d", "ab"}, false) = "dcabe" + * StringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"d", "t"}, false) = "dcte" + * StringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"d", "t"}, true) = "tcte" + * StringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"d", "ab"}, true) = IllegalArgumentException + * StringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"d", "ab"}, false) = "dcabe" ** * @param text @@ -3617,19 +3619,19 @@ public static String replaceEachRepeatedly(String text, String[] searchList, Str * * *
- * StringUtils.replaceEach(null, *, *, *) = null - * StringUtils.replaceEach("", *, *, *) = "" + * StringUtils.replaceEach(null, *, *, *) = null + * StringUtils.replaceEach("", *, *, *) = "" * StringUtils.replaceEach("aba", null, null, *) = "aba" * StringUtils.replaceEach("aba", new String[0], null, *) = "aba" * StringUtils.replaceEach("aba", null, new String[0], *) = "aba" - * StringUtils.replaceEach("aba", new String[]{"a"}, null, *) = "aba" - * StringUtils.replaceEach("aba", new String[]{"a"}, new String[]{""}, *) = "b" - * StringUtils.replaceEach("aba", new String[]{null}, new String[]{"a"}, *) = "aba" - * StringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"w", "t"}, *) = "wcte" + * StringUtils.replaceEach("aba", new String[]{"a"}, null, *) = "aba" + * StringUtils.replaceEach("aba", new String[]{"a"}, new String[]{""}, *) = "b" + * StringUtils.replaceEach("aba", new String[]{null}, new String[]{"a"}, *) = "aba" + * StringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"w", "t"}, *) = "wcte" * (example of how it repeats) - * StringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"d", "t"}, false) = "dcte" - * StringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"d", "t"}, true) = "tcte" - * StringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"d", "ab"}, *) = IllegalArgumentException + * StringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"d", "t"}, false) = "dcte" + * StringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"d", "t"}, true) = "tcte" + * StringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"d", "ab"}, *) = IllegalArgumentException ** * @param text @@ -3653,12 +3655,16 @@ public static String replaceEachRepeatedly(String text, String[] searchList, Str * and/or size 0) * @since 2.4 */ - private static String replaceEach(String text, String[] searchList, String[] replacementList, boolean repeat, int timeToLive) { + private static String replaceEach(String text, String[] searchList, String[] replacementList, + boolean repeat, int timeToLive) + { // mchyzer Performance note: This creates very few new objects (one major goal) // let me know if there are performance requests, we can create a harness to measure - if (text == null || text.length() == 0 || searchList == null || searchList.length == 0 || replacementList == null || replacementList.length == 0) { + if (text == null || text.length() == 0 || searchList == null || + searchList.length == 0 || replacementList == null || replacementList.length == 0) + { return text; } @@ -3689,7 +3695,9 @@ private static String replaceEach(String text, String[] searchList, String[] rep // index of replace array that will replace the search string found // NOTE: logic duplicated below START for (int i = 0; i < searchLength; i++) { - if (noMoreMatchesForReplIndex[i] || searchList[i] == null || searchList[i].length() == 0 || replacementList[i] == null) { + if (noMoreMatchesForReplIndex[i] || searchList[i] == null || + searchList[i].length() == 0 || replacementList[i] == null) + { continue; } tempIndex = text.indexOf(searchList[i]); @@ -3743,7 +3751,9 @@ private static String replaceEach(String text, String[] searchList, String[] rep // find the next earliest match // NOTE: logic mostly duplicated above START for (int i = 0; i < searchLength; i++) { - if (noMoreMatchesForReplIndex[i] || searchList[i] == null || searchList[i].length() == 0 || replacementList[i] == null) { + if (noMoreMatchesForReplIndex[i] || searchList[i] == null || + searchList[i].length() == 0 || replacementList[i] == null) + { continue; } tempIndex = text.indexOf(searchList[i], start); diff --git a/src/java/org/apache/commons/lang/text/ExtendedMessageFormat.java b/src/java/org/apache/commons/lang/text/ExtendedMessageFormat.java index 1a4581337..404be490c 100644 --- a/src/java/org/apache/commons/lang/text/ExtendedMessageFormat.java +++ b/src/java/org/apache/commons/lang/text/ExtendedMessageFormat.java @@ -36,7 +36,7 @@ * and the formats supported by
java.text.MessageFormat
can be overridden
* at the format and/or format style level (see MessageFormat). A "format element"
* embedded in the message pattern is specified (()? signifies optionality):{
argument-number(,
format-name(,
format-style)?)?}
+ * {
argument-number(,
format-name(,
format-style)?)?}
*
* * format-name and format-style values are trimmed of surrounding whitespace @@ -192,7 +192,8 @@ public final void applyPattern(String pattern) { toPattern = insertFormats(super.toPattern(), foundDescriptions); if (containsElements(foundFormats)) { Format[] origFormats = getFormats(); - //only loop over what we know we have, as MessageFormat on Java 1.3 seems to provide an extra format element: + // only loop over what we know we have, as MessageFormat on Java 1.3 + // seems to provide an extra format element: int i = 0; for (Iterator it = foundFormats.iterator(); it.hasNext(); i++) { Format f = (Format) it.next();