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;
}
}
return new StringBuilder(annotationType == null ? "" : annotationType.getName())
return new StringBuilder(annotationType == null ? StringUtils.EMPTY : annotationType.getName())
.insert(0, '@').toString();
}

View File

@ -79,7 +79,7 @@ public class CharSet implements Serializable {
static {
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-z", ASCII_ALPHA_LOWER);

View File

@ -91,7 +91,7 @@ public class LocaleUtils {
return null;
}
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
throw new IllegalArgumentException("Invalid locale format: " + str);
@ -111,7 +111,7 @@ public class LocaleUtils {
throw new IllegalArgumentException("Invalid locale format: " + str);
}
if (len == 3) {
return new Locale("", str.substring(1, 3));
return new Locale(StringUtils.EMPTY, str.substring(1, 3));
}
if (len < 5) {
throw new IllegalArgumentException("Invalid locale format: " + str);
@ -119,7 +119,7 @@ public class LocaleUtils {
if (str.charAt(3) != '_') {
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);
@ -196,7 +196,7 @@ public class LocaleUtils {
list.add(new Locale(locale.getLanguage(), locale.getCountry()));
}
if (locale.getCountry().length() > 0) {
list.add(new Locale(locale.getLanguage(), ""));
list.add(new Locale(locale.getLanguage(), StringUtils.EMPTY));
}
if (list.contains(defaultLocale) == false) {
list.add(defaultLocale);

View File

@ -388,7 +388,7 @@ public class ObjectUtils {
*/
@Deprecated
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,
final char[] chars, final Random random) {
if (count == 0) {
return "";
return StringUtils.EMPTY;
} else if (count < 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(
new String[][] {
{ "\u0000", "" },
{ "\u0001", "" },
{ "\u0002", "" },
{ "\u0003", "" },
{ "\u0004", "" },
{ "\u0005", "" },
{ "\u0006", "" },
{ "\u0007", "" },
{ "\u0008", "" },
{ "\u000b", "" },
{ "\u000c", "" },
{ "\u000e", "" },
{ "\u000f", "" },
{ "\u0010", "" },
{ "\u0011", "" },
{ "\u0012", "" },
{ "\u0013", "" },
{ "\u0014", "" },
{ "\u0015", "" },
{ "\u0016", "" },
{ "\u0017", "" },
{ "\u0018", "" },
{ "\u0019", "" },
{ "\u001a", "" },
{ "\u001b", "" },
{ "\u001c", "" },
{ "\u001d", "" },
{ "\u001e", "" },
{ "\u001f", "" },
{ "\ufffe", "" },
{ "\uffff", "" }
{ "\u0000", StringUtils.EMPTY },
{ "\u0001", StringUtils.EMPTY },
{ "\u0002", StringUtils.EMPTY },
{ "\u0003", StringUtils.EMPTY },
{ "\u0004", StringUtils.EMPTY },
{ "\u0005", StringUtils.EMPTY },
{ "\u0006", StringUtils.EMPTY },
{ "\u0007", StringUtils.EMPTY },
{ "\u0008", StringUtils.EMPTY },
{ "\u000b", StringUtils.EMPTY },
{ "\u000c", StringUtils.EMPTY },
{ "\u000e", StringUtils.EMPTY },
{ "\u000f", StringUtils.EMPTY },
{ "\u0010", StringUtils.EMPTY },
{ "\u0011", StringUtils.EMPTY },
{ "\u0012", StringUtils.EMPTY },
{ "\u0013", StringUtils.EMPTY },
{ "\u0014", StringUtils.EMPTY },
{ "\u0015", StringUtils.EMPTY },
{ "\u0016", StringUtils.EMPTY },
{ "\u0017", StringUtils.EMPTY },
{ "\u0018", StringUtils.EMPTY },
{ "\u0019", StringUtils.EMPTY },
{ "\u001a", StringUtils.EMPTY },
{ "\u001b", StringUtils.EMPTY },
{ "\u001c", StringUtils.EMPTY },
{ "\u001d", StringUtils.EMPTY },
{ "\u001e", StringUtils.EMPTY },
{ "\u001f", StringUtils.EMPTY },
{ "\ufffe", StringUtils.EMPTY },
{ "\uffff", StringUtils.EMPTY }
}),
NumericEntityEscaper.between(0x7f, 0x84),
NumericEntityEscaper.between(0x86, 0x9f),
@ -188,11 +188,11 @@ public class StringEscapeUtils {
new LookupTranslator(EntityArrays.APOS_ESCAPE()),
new LookupTranslator(
new String[][] {
{ "\u0000", "" },
{ "\u0000", StringUtils.EMPTY },
{ "\u000b", "&#11;" },
{ "\u000c", "&#12;" },
{ "\ufffe", "" },
{ "\uffff", "" }
{ "\ufffe", StringUtils.EMPTY },
{ "\uffff", StringUtils.EMPTY }
}),
NumericEntityEscaper.between(0x1, 0x8),
NumericEntityEscaper.between(0xe, 0x1f),

View File

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

View File

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

View File

@ -670,7 +670,7 @@ public class ExceptionUtils {
*/
public static String getMessage(final Throwable th) {
if (th == null) {
return "";
return StringUtils.EMPTY;
}
final String clsName = ClassUtils.getShortClassName(th, null);
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.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import org.apache.commons.lang3.builder.Builder;
@ -1501,7 +1502,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
ensureCapacity(size + width);
String str = (obj == null ? getNullText() : obj.toString());
if (str == null) {
str = "";
str = StringUtils.EMPTY;
}
final int strLen = str.length();
if (strLen >= width) {
@ -1548,7 +1549,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
ensureCapacity(size + width);
String str = (obj == null ? getNullText() : obj.toString());
if (str == null) {
str = "";
str = StringUtils.EMPTY;
}
final int strLen = str.length();
if (strLen >= width) {
@ -2292,7 +2293,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
*/
public String leftString(final int length) {
if (length <= 0) {
return "";
return StringUtils.EMPTY;
} else if (length >= size) {
return new String(buffer, 0, size);
} else {
@ -2314,7 +2315,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
*/
public String rightString(final int length) {
if (length <= 0) {
return "";
return StringUtils.EMPTY;
} else if (length >= size) {
return new String(buffer, 0, size);
} else {
@ -2343,7 +2344,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
index = 0;
}
if (length <= 0 || index >= size) {
return "";
return StringUtils.EMPTY;
}
if (size <= index + length) {
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
if (pos >= count) {
addToken(tokenList, "");
addToken(tokenList, StringUtils.EMPTY);
}
}
return tokenList;
@ -698,14 +698,14 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
// handle reaching end
if (start >= len) {
addToken(tokenList, "");
addToken(tokenList, StringUtils.EMPTY);
return -1;
}
// handle empty token
final int delimLen = getDelimiterMatcher().isMatch(srcChars, start, start, len);
if (delimLen > 0) {
addToken(tokenList, "");
addToken(tokenList, StringUtils.EMPTY);
return start + delimLen;
}

View File

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

View File

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