This commit is contained in:
ggregory 2016-04-13 13:57:35 -07:00
parent a6d27fd89d
commit 15b80753a6
13 changed files with 77 additions and 75 deletions

View File

@ -79,7 +79,7 @@ public class AnnotationUtils {
break; break;
} }
} }
return new StringBuilder(annotationType == null ? "" : annotationType.getName()) return new StringBuilder(annotationType == null ? StringUtils.EMPTY : annotationType.getName())
.insert(0, '@').toString(); .insert(0, '@').toString();
} }

View File

@ -79,7 +79,7 @@ public class CharSet implements Serializable {
static { static {
COMMON.put(null, EMPTY); COMMON.put(null, EMPTY);
COMMON.put("", EMPTY); COMMON.put(StringUtils.EMPTY, EMPTY);
COMMON.put("a-zA-Z", ASCII_ALPHA); COMMON.put("a-zA-Z", ASCII_ALPHA);
COMMON.put("A-Za-z", ASCII_ALPHA); COMMON.put("A-Za-z", ASCII_ALPHA);
COMMON.put("a-z", ASCII_ALPHA_LOWER); COMMON.put("a-z", ASCII_ALPHA_LOWER);

View File

@ -91,7 +91,7 @@ public class LocaleUtils {
return null; return null;
} }
if (str.isEmpty()) { // LANG-941 - JDK 8 introduced an empty locale where all fields are blank if (str.isEmpty()) { // LANG-941 - JDK 8 introduced an empty locale where all fields are blank
return new Locale("", ""); return new Locale(StringUtils.EMPTY, StringUtils.EMPTY);
} }
if (str.contains("#")) { // LANG-879 - Cannot handle Java 7 script & extensions if (str.contains("#")) { // LANG-879 - Cannot handle Java 7 script & extensions
throw new IllegalArgumentException("Invalid locale format: " + str); throw new IllegalArgumentException("Invalid locale format: " + str);
@ -111,7 +111,7 @@ public class LocaleUtils {
throw new IllegalArgumentException("Invalid locale format: " + str); throw new IllegalArgumentException("Invalid locale format: " + str);
} }
if (len == 3) { if (len == 3) {
return new Locale("", str.substring(1, 3)); return new Locale(StringUtils.EMPTY, str.substring(1, 3));
} }
if (len < 5) { if (len < 5) {
throw new IllegalArgumentException("Invalid locale format: " + str); throw new IllegalArgumentException("Invalid locale format: " + str);
@ -119,7 +119,7 @@ public class LocaleUtils {
if (str.charAt(3) != '_') { if (str.charAt(3) != '_') {
throw new IllegalArgumentException("Invalid locale format: " + str); throw new IllegalArgumentException("Invalid locale format: " + str);
} }
return new Locale("", str.substring(1, 3), str.substring(4)); return new Locale(StringUtils.EMPTY, str.substring(1, 3), str.substring(4));
} }
final String[] split = str.split("_", -1); final String[] split = str.split("_", -1);
@ -196,7 +196,7 @@ public class LocaleUtils {
list.add(new Locale(locale.getLanguage(), locale.getCountry())); list.add(new Locale(locale.getLanguage(), locale.getCountry()));
} }
if (locale.getCountry().length() > 0) { if (locale.getCountry().length() > 0) {
list.add(new Locale(locale.getLanguage(), "")); list.add(new Locale(locale.getLanguage(), StringUtils.EMPTY));
} }
if (list.contains(defaultLocale) == false) { if (list.contains(defaultLocale) == false) {
list.add(defaultLocale); list.add(defaultLocale);

View File

@ -388,7 +388,7 @@ public class ObjectUtils {
*/ */
@Deprecated @Deprecated
public static String toString(final Object obj) { public static String toString(final Object obj) {
return obj == null ? "" : obj.toString(); return obj == null ? StringUtils.EMPTY : obj.toString();
} }
/** /**

View File

@ -222,7 +222,7 @@ public class RandomStringUtils {
public static String random(int count, int start, int end, final boolean letters, final boolean numbers, public static String random(int count, int start, int end, final boolean letters, final boolean numbers,
final char[] chars, final Random random) { final char[] chars, final Random random) {
if (count == 0) { if (count == 0) {
return ""; return StringUtils.EMPTY;
} else if (count < 0) { } else if (count < 0) {
throw new IllegalArgumentException("Requested random string length " + count + " is less than 0."); throw new IllegalArgumentException("Requested random string length " + count + " is less than 0.");
} }

View File

@ -136,37 +136,37 @@ public class StringEscapeUtils {
new LookupTranslator(EntityArrays.APOS_ESCAPE()), new LookupTranslator(EntityArrays.APOS_ESCAPE()),
new LookupTranslator( new LookupTranslator(
new String[][] { new String[][] {
{ "\u0000", "" }, { "\u0000", StringUtils.EMPTY },
{ "\u0001", "" }, { "\u0001", StringUtils.EMPTY },
{ "\u0002", "" }, { "\u0002", StringUtils.EMPTY },
{ "\u0003", "" }, { "\u0003", StringUtils.EMPTY },
{ "\u0004", "" }, { "\u0004", StringUtils.EMPTY },
{ "\u0005", "" }, { "\u0005", StringUtils.EMPTY },
{ "\u0006", "" }, { "\u0006", StringUtils.EMPTY },
{ "\u0007", "" }, { "\u0007", StringUtils.EMPTY },
{ "\u0008", "" }, { "\u0008", StringUtils.EMPTY },
{ "\u000b", "" }, { "\u000b", StringUtils.EMPTY },
{ "\u000c", "" }, { "\u000c", StringUtils.EMPTY },
{ "\u000e", "" }, { "\u000e", StringUtils.EMPTY },
{ "\u000f", "" }, { "\u000f", StringUtils.EMPTY },
{ "\u0010", "" }, { "\u0010", StringUtils.EMPTY },
{ "\u0011", "" }, { "\u0011", StringUtils.EMPTY },
{ "\u0012", "" }, { "\u0012", StringUtils.EMPTY },
{ "\u0013", "" }, { "\u0013", StringUtils.EMPTY },
{ "\u0014", "" }, { "\u0014", StringUtils.EMPTY },
{ "\u0015", "" }, { "\u0015", StringUtils.EMPTY },
{ "\u0016", "" }, { "\u0016", StringUtils.EMPTY },
{ "\u0017", "" }, { "\u0017", StringUtils.EMPTY },
{ "\u0018", "" }, { "\u0018", StringUtils.EMPTY },
{ "\u0019", "" }, { "\u0019", StringUtils.EMPTY },
{ "\u001a", "" }, { "\u001a", StringUtils.EMPTY },
{ "\u001b", "" }, { "\u001b", StringUtils.EMPTY },
{ "\u001c", "" }, { "\u001c", StringUtils.EMPTY },
{ "\u001d", "" }, { "\u001d", StringUtils.EMPTY },
{ "\u001e", "" }, { "\u001e", StringUtils.EMPTY },
{ "\u001f", "" }, { "\u001f", StringUtils.EMPTY },
{ "\ufffe", "" }, { "\ufffe", StringUtils.EMPTY },
{ "\uffff", "" } { "\uffff", StringUtils.EMPTY }
}), }),
NumericEntityEscaper.between(0x7f, 0x84), NumericEntityEscaper.between(0x7f, 0x84),
NumericEntityEscaper.between(0x86, 0x9f), NumericEntityEscaper.between(0x86, 0x9f),
@ -188,11 +188,11 @@ public class StringEscapeUtils {
new LookupTranslator(EntityArrays.APOS_ESCAPE()), new LookupTranslator(EntityArrays.APOS_ESCAPE()),
new LookupTranslator( new LookupTranslator(
new String[][] { new String[][] {
{ "\u0000", "" }, { "\u0000", StringUtils.EMPTY },
{ "\u000b", "&#11;" }, { "\u000b", "&#11;" },
{ "\u000c", "&#12;" }, { "\u000c", "&#12;" },
{ "\ufffe", "" }, { "\ufffe", StringUtils.EMPTY },
{ "\uffff", "" } { "\uffff", StringUtils.EMPTY }
}), }),
NumericEntityEscaper.between(0x1, 0x8), NumericEntityEscaper.between(0x1, 0x8),
NumericEntityEscaper.between(0xe, 0x1f), NumericEntityEscaper.between(0xe, 0x1f),

View File

@ -755,7 +755,7 @@ public class StringUtils {
final Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");//$NON-NLS-1$ final Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");//$NON-NLS-1$
final String decomposed = Normalizer.normalize(input, Normalizer.Form.NFD); final String decomposed = Normalizer.normalize(input, Normalizer.Form.NFD);
// Note that this doesn't correctly remove ligatures... // Note that this doesn't correctly remove ligatures...
return pattern.matcher(decomposed).replaceAll("");//$NON-NLS-1$ return pattern.matcher(decomposed).replaceAll(StringUtils.EMPTY);
} }
// Equals // Equals

View File

@ -24,6 +24,7 @@ import java.util.WeakHashMap;
import org.apache.commons.lang3.ClassUtils; import org.apache.commons.lang3.ClassUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils; import org.apache.commons.lang3.SystemUtils;
/** /**
@ -1768,7 +1769,7 @@ public abstract class ToStringStyle implements Serializable {
*/ */
protected void setArrayStart(String arrayStart) { protected void setArrayStart(String arrayStart) {
if (arrayStart == null) { if (arrayStart == null) {
arrayStart = ""; arrayStart = StringUtils.EMPTY;
} }
this.arrayStart = arrayStart; this.arrayStart = arrayStart;
} }
@ -1794,7 +1795,7 @@ public abstract class ToStringStyle implements Serializable {
*/ */
protected void setArrayEnd(String arrayEnd) { protected void setArrayEnd(String arrayEnd) {
if (arrayEnd == null) { if (arrayEnd == null) {
arrayEnd = ""; arrayEnd = StringUtils.EMPTY;
} }
this.arrayEnd = arrayEnd; this.arrayEnd = arrayEnd;
} }
@ -1820,7 +1821,7 @@ public abstract class ToStringStyle implements Serializable {
*/ */
protected void setArraySeparator(String arraySeparator) { protected void setArraySeparator(String arraySeparator) {
if (arraySeparator == null) { if (arraySeparator == null) {
arraySeparator = ""; arraySeparator = StringUtils.EMPTY;
} }
this.arraySeparator = arraySeparator; this.arraySeparator = arraySeparator;
} }
@ -1846,7 +1847,7 @@ public abstract class ToStringStyle implements Serializable {
*/ */
protected void setContentStart(String contentStart) { protected void setContentStart(String contentStart) {
if (contentStart == null) { if (contentStart == null) {
contentStart = ""; contentStart = StringUtils.EMPTY;
} }
this.contentStart = contentStart; this.contentStart = contentStart;
} }
@ -1872,7 +1873,7 @@ public abstract class ToStringStyle implements Serializable {
*/ */
protected void setContentEnd(String contentEnd) { protected void setContentEnd(String contentEnd) {
if (contentEnd == null) { if (contentEnd == null) {
contentEnd = ""; contentEnd = StringUtils.EMPTY;
} }
this.contentEnd = contentEnd; this.contentEnd = contentEnd;
} }
@ -1898,7 +1899,7 @@ public abstract class ToStringStyle implements Serializable {
*/ */
protected void setFieldNameValueSeparator(String fieldNameValueSeparator) { protected void setFieldNameValueSeparator(String fieldNameValueSeparator) {
if (fieldNameValueSeparator == null) { if (fieldNameValueSeparator == null) {
fieldNameValueSeparator = ""; fieldNameValueSeparator = StringUtils.EMPTY;
} }
this.fieldNameValueSeparator = fieldNameValueSeparator; this.fieldNameValueSeparator = fieldNameValueSeparator;
} }
@ -1924,7 +1925,7 @@ public abstract class ToStringStyle implements Serializable {
*/ */
protected void setFieldSeparator(String fieldSeparator) { protected void setFieldSeparator(String fieldSeparator) {
if (fieldSeparator == null) { if (fieldSeparator == null) {
fieldSeparator = ""; fieldSeparator = StringUtils.EMPTY;
} }
this.fieldSeparator = fieldSeparator; this.fieldSeparator = fieldSeparator;
} }
@ -1998,7 +1999,7 @@ public abstract class ToStringStyle implements Serializable {
*/ */
protected void setNullText(String nullText) { protected void setNullText(String nullText) {
if (nullText == null) { if (nullText == null) {
nullText = ""; nullText = StringUtils.EMPTY;
} }
this.nullText = nullText; this.nullText = nullText;
} }
@ -2030,7 +2031,7 @@ public abstract class ToStringStyle implements Serializable {
*/ */
protected void setSizeStartText(String sizeStartText) { protected void setSizeStartText(String sizeStartText) {
if (sizeStartText == null) { if (sizeStartText == null) {
sizeStartText = ""; sizeStartText = StringUtils.EMPTY;
} }
this.sizeStartText = sizeStartText; this.sizeStartText = sizeStartText;
} }
@ -2062,7 +2063,7 @@ public abstract class ToStringStyle implements Serializable {
*/ */
protected void setSizeEndText(String sizeEndText) { protected void setSizeEndText(String sizeEndText) {
if (sizeEndText == null) { if (sizeEndText == null) {
sizeEndText = ""; sizeEndText = StringUtils.EMPTY;
} }
this.sizeEndText = sizeEndText; this.sizeEndText = sizeEndText;
} }
@ -2094,7 +2095,7 @@ public abstract class ToStringStyle implements Serializable {
*/ */
protected void setSummaryObjectStartText(String summaryObjectStartText) { protected void setSummaryObjectStartText(String summaryObjectStartText) {
if (summaryObjectStartText == null) { if (summaryObjectStartText == null) {
summaryObjectStartText = ""; summaryObjectStartText = StringUtils.EMPTY;
} }
this.summaryObjectStartText = summaryObjectStartText; this.summaryObjectStartText = summaryObjectStartText;
} }
@ -2126,7 +2127,7 @@ public abstract class ToStringStyle implements Serializable {
*/ */
protected void setSummaryObjectEndText(String summaryObjectEndText) { protected void setSummaryObjectEndText(String summaryObjectEndText) {
if (summaryObjectEndText == null) { if (summaryObjectEndText == null) {
summaryObjectEndText = ""; summaryObjectEndText = StringUtils.EMPTY;
} }
this.summaryObjectEndText = summaryObjectEndText; this.summaryObjectEndText = summaryObjectEndText;
} }
@ -2259,8 +2260,8 @@ public abstract class ToStringStyle implements Serializable {
this.setUseClassName(false); this.setUseClassName(false);
this.setUseIdentityHashCode(false); this.setUseIdentityHashCode(false);
this.setUseFieldNames(false); this.setUseFieldNames(false);
this.setContentStart(""); this.setContentStart(StringUtils.EMPTY);
this.setContentEnd(""); this.setContentEnd(StringUtils.EMPTY);
} }
/** /**

View File

@ -670,7 +670,7 @@ public class ExceptionUtils {
*/ */
public static String getMessage(final Throwable th) { public static String getMessage(final Throwable th) {
if (th == null) { if (th == null) {
return ""; return StringUtils.EMPTY;
} }
final String clsName = ClassUtils.getShortClassName(th, null); final String clsName = ClassUtils.getShortClassName(th, null);
final String msg = th.getMessage(); final String msg = th.getMessage();

View File

@ -26,6 +26,7 @@ import java.util.List;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils; import org.apache.commons.lang3.SystemUtils;
import org.apache.commons.lang3.builder.Builder; import org.apache.commons.lang3.builder.Builder;
@ -1501,7 +1502,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
ensureCapacity(size + width); ensureCapacity(size + width);
String str = (obj == null ? getNullText() : obj.toString()); String str = (obj == null ? getNullText() : obj.toString());
if (str == null) { if (str == null) {
str = ""; str = StringUtils.EMPTY;
} }
final int strLen = str.length(); final int strLen = str.length();
if (strLen >= width) { if (strLen >= width) {
@ -1548,7 +1549,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
ensureCapacity(size + width); ensureCapacity(size + width);
String str = (obj == null ? getNullText() : obj.toString()); String str = (obj == null ? getNullText() : obj.toString());
if (str == null) { if (str == null) {
str = ""; str = StringUtils.EMPTY;
} }
final int strLen = str.length(); final int strLen = str.length();
if (strLen >= width) { if (strLen >= width) {
@ -2292,7 +2293,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
*/ */
public String leftString(final int length) { public String leftString(final int length) {
if (length <= 0) { if (length <= 0) {
return ""; return StringUtils.EMPTY;
} else if (length >= size) { } else if (length >= size) {
return new String(buffer, 0, size); return new String(buffer, 0, size);
} else { } else {
@ -2314,7 +2315,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
*/ */
public String rightString(final int length) { public String rightString(final int length) {
if (length <= 0) { if (length <= 0) {
return ""; return StringUtils.EMPTY;
} else if (length >= size) { } else if (length >= size) {
return new String(buffer, 0, size); return new String(buffer, 0, size);
} else { } else {
@ -2343,7 +2344,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
index = 0; index = 0;
} }
if (length <= 0 || index >= size) { if (length <= 0 || index >= size) {
return ""; return StringUtils.EMPTY;
} }
if (size <= index + length) { if (size <= index + length) {
return new String(buffer, index, size - index); return new String(buffer, index, size - index);

View File

@ -646,7 +646,7 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
// handle case where end of string is a delimiter // handle case where end of string is a delimiter
if (pos >= count) { if (pos >= count) {
addToken(tokenList, ""); addToken(tokenList, StringUtils.EMPTY);
} }
} }
return tokenList; return tokenList;
@ -698,14 +698,14 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
// handle reaching end // handle reaching end
if (start >= len) { if (start >= len) {
addToken(tokenList, ""); addToken(tokenList, StringUtils.EMPTY);
return -1; return -1;
} }
// handle empty token // handle empty token
final int delimLen = getDelimiterMatcher().isMatch(srcChars, start, start, len); final int delimLen = getDelimiterMatcher().isMatch(srcChars, start, start, len);
if (delimLen > 0) { if (delimLen > 0) {
addToken(tokenList, ""); addToken(tokenList, StringUtils.EMPTY);
return start + delimLen; return start + delimLen;
} }

View File

@ -541,7 +541,7 @@ public class WordUtils {
return str; return str;
} }
if (delimiters != null && delimiters.length == 0) { if (delimiters != null && delimiters.length == 0) {
return ""; return StringUtils.EMPTY;
} }
final int strLen = str.length(); final int strLen = str.length();
final char[] buf = new char[strLen / 2 + 1]; final char[] buf = new char[strLen / 2 + 1];

View File

@ -181,16 +181,16 @@ public class DurationFormatUtils {
if (suppressLeadingZeroElements) { if (suppressLeadingZeroElements) {
// this is a temporary marker on the front. Like ^ in regexp. // this is a temporary marker on the front. Like ^ in regexp.
duration = " " + duration; duration = " " + duration;
String tmp = StringUtils.replaceOnce(duration, " 0 days", ""); String tmp = StringUtils.replaceOnce(duration, " 0 days", StringUtils.EMPTY);
if (tmp.length() != duration.length()) { if (tmp.length() != duration.length()) {
duration = tmp; duration = tmp;
tmp = StringUtils.replaceOnce(duration, " 0 hours", ""); tmp = StringUtils.replaceOnce(duration, " 0 hours", StringUtils.EMPTY);
if (tmp.length() != duration.length()) { if (tmp.length() != duration.length()) {
duration = tmp; duration = tmp;
tmp = StringUtils.replaceOnce(duration, " 0 minutes", ""); tmp = StringUtils.replaceOnce(duration, " 0 minutes", StringUtils.EMPTY);
duration = tmp; duration = tmp;
if (tmp.length() != duration.length()) { if (tmp.length() != duration.length()) {
duration = StringUtils.replaceOnce(tmp, " 0 seconds", ""); duration = StringUtils.replaceOnce(tmp, " 0 seconds", StringUtils.EMPTY);
} }
} }
} }
@ -200,15 +200,15 @@ public class DurationFormatUtils {
} }
} }
if (suppressTrailingZeroElements) { if (suppressTrailingZeroElements) {
String tmp = StringUtils.replaceOnce(duration, " 0 seconds", ""); String tmp = StringUtils.replaceOnce(duration, " 0 seconds", StringUtils.EMPTY);
if (tmp.length() != duration.length()) { if (tmp.length() != duration.length()) {
duration = tmp; duration = tmp;
tmp = StringUtils.replaceOnce(duration, " 0 minutes", ""); tmp = StringUtils.replaceOnce(duration, " 0 minutes", StringUtils.EMPTY);
if (tmp.length() != duration.length()) { if (tmp.length() != duration.length()) {
duration = tmp; duration = tmp;
tmp = StringUtils.replaceOnce(duration, " 0 hours", ""); tmp = StringUtils.replaceOnce(duration, " 0 hours", StringUtils.EMPTY);
if (tmp.length() != duration.length()) { if (tmp.length() != duration.length()) {
duration = StringUtils.replaceOnce(tmp, " 0 days", ""); duration = StringUtils.replaceOnce(tmp, " 0 days", StringUtils.EMPTY);
} }
} }
} }