public final class StringUtil
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static void |
appendXmlEscaped(java.lang.StringBuilder buf,
java.lang.String src,
boolean supportUTF8) |
static boolean |
areSemanticEquals(java.lang.String a,
java.lang.String b)
Deprecated.
|
static java.lang.String |
asString(java.lang.Object[] items,
java.lang.String separator)
Formats all items onto a string with separators if more than one exists,
return an empty string if the items are null or empty.
|
static void |
asStringOn(java.lang.StringBuffer sb,
java.util.Iterator<?> iter,
java.lang.String separator)
Deprecated.
StringUtils.join(Iterator, String) |
static void |
asStringOn(java.lang.StringBuilder sb,
java.lang.Object[] items,
java.lang.String separator)
Deprecated.
StringUtils.join(Iterable, String) |
static java.lang.String |
escapeWhitespace(java.lang.Object o)
Replace some whitespace characters so they are visually apparent.
|
static java.lang.String[] |
getEmptyStrings()
Returns an empty array of string
|
static boolean |
isAnyOf(java.lang.String text,
java.lang.String... tests)
Returns whether the non-null text arg matches any of the test values.
|
static boolean |
isEmpty(java.lang.String value)
Deprecated.
StringUtils.isBlank(CharSequence) |
static boolean |
isMissing(java.lang.String value)
Deprecated.
StringUtils.isEmpty(CharSequence) |
static boolean |
isNotEmpty(java.lang.String value)
Deprecated.
StringUtils.isNotBlank(CharSequence) |
static boolean |
isSame(java.lang.String s1,
java.lang.String s2,
boolean trim,
boolean ignoreCase,
boolean standardizeWhitespace)
Are the two String values the same.
|
static int |
lengthOfShortestIn(java.lang.String[] strings)
Return the length of the shortest string in the array.
|
static java.lang.String |
lpad(java.lang.String s,
int length)
Deprecated.
StringUtils.leftPad(String, int) |
static int |
maxCommonLeadingWhitespaceForAll(java.lang.String[] strings)
Determine the maximum number of common leading whitespace characters the
strings share in the same sequence.
|
static java.lang.String |
percentageString(double val,
int numDecimals)
Formats a double to a percentage, keeping
numDecimal decimal places. |
static java.lang.String |
replaceString(java.lang.String original,
char oldChar,
java.lang.String newString)
Deprecated.
StringUtils.replace(String, String, String) or StringUtils.replaceChars(String, char, char) |
static java.lang.String |
replaceString(java.lang.String original,
java.lang.String oldString,
java.lang.String newString)
Deprecated.
StringUtils.replace(String, String, String) |
static boolean |
startsWithAny(java.lang.String text,
java.lang.String... prefixes)
Deprecated.
StringUtils.startsWithAny(CharSequence, CharSequence...) |
static java.lang.String[] |
substringsOf(java.lang.String source,
char delimiter)
Deprecated.
StringUtils.split(String, char) |
static java.lang.String[] |
substringsOf(java.lang.String str,
java.lang.String separator)
Deprecated.
StringUtils.split(String, String) |
static java.lang.String[] |
trimStartOn(java.lang.String[] strings,
int trimDepth)
Trims off the leading characters off the strings up to the trimDepth
specified.
|
static java.lang.String |
withoutPrefixes(java.lang.String text,
java.lang.String... prefixes)
Checks for the existence of any of the listed prefixes on the non-null
text and removes them.
|
public static java.lang.String percentageString(double val, int numDecimals)
numDecimal
decimal places.val
- a double value between 0 and 1numDecimals
- The number of decimal places to keepjava.lang.IllegalArgumentException
- if the double to format is not between 0 and 1@Deprecated public static boolean startsWithAny(java.lang.String text, java.lang.String... prefixes)
StringUtils.startsWithAny(CharSequence, CharSequence...)
text
- prefixes
- public static boolean isAnyOf(java.lang.String text, java.lang.String... tests)
text
- tests
- public static java.lang.String withoutPrefixes(java.lang.String text, java.lang.String... prefixes)
text
- prefixes
- @Deprecated public static boolean isNotEmpty(java.lang.String value)
StringUtils.isNotBlank(CharSequence)
value
- String@Deprecated public static boolean isEmpty(java.lang.String value)
StringUtils.isBlank(CharSequence)
value
- String to testtrue
if the value is empty, false
otherwise.@Deprecated public static boolean isMissing(java.lang.String value)
StringUtils.isEmpty(CharSequence)
value
- String to test@Deprecated public static boolean areSemanticEquals(java.lang.String a, java.lang.String b)
a
- b
- @Deprecated public static java.lang.String replaceString(java.lang.String original, java.lang.String oldString, java.lang.String newString)
StringUtils.replace(String, String, String)
original
- StringoldString
- StringnewString
- Stringpublic static void appendXmlEscaped(java.lang.StringBuilder buf, java.lang.String src, boolean supportUTF8)
buf
- src
- supportUTF8
- override the default setting, whether special characters should be replaced with entities (
false
) or should be included as is ( true
).public static java.lang.String escapeWhitespace(java.lang.Object o)
o
- @Deprecated public static java.lang.String replaceString(java.lang.String original, char oldChar, java.lang.String newString)
StringUtils.replace(String, String, String)
or StringUtils.replaceChars(String, char, char)
original
- StringoldChar
- charnewString
- String@Deprecated public static java.lang.String[] substringsOf(java.lang.String source, char delimiter)
StringUtils.split(String, char)
source
- Stringdelimiter
- char@Deprecated public static java.lang.String[] substringsOf(java.lang.String str, java.lang.String separator)
StringUtils.split(String, String)
str
- Stringseparator
- char@Deprecated public static void asStringOn(java.lang.StringBuffer sb, java.util.Iterator<?> iter, java.lang.String separator)
StringUtils.join(Iterator, String)
sb
- StringBufferiter
- Iteratorseparator
- String@Deprecated public static void asStringOn(java.lang.StringBuilder sb, java.lang.Object[] items, java.lang.String separator)
StringUtils.join(Iterable, String)
sb
- StringBuilderitems
- Object[]separator
- Stringpublic static int maxCommonLeadingWhitespaceForAll(java.lang.String[] strings)
strings
- String[]public static int lengthOfShortestIn(java.lang.String[] strings)
strings
- String[]public static java.lang.String[] trimStartOn(java.lang.String[] strings, int trimDepth)
strings
- trimDepth
- @Deprecated public static java.lang.String lpad(java.lang.String s, int length)
StringUtils.leftPad(String, int)
s
- The String to padlength
- The desired minimum length of the resulting padded Stringpublic static boolean isSame(java.lang.String s1, java.lang.String s2, boolean trim, boolean ignoreCase, boolean standardizeWhitespace)
s1
- The first String.s2
- The second String.trim
- Indicates if the Strings should be trimmed before comparison.ignoreCase
- Indicates if the case of the Strings should ignored during comparison.standardizeWhitespace
- Indicates if the embedded whitespace should be standardized before comparison.true
if the Strings are the same, false
otherwise.public static java.lang.String asString(java.lang.Object[] items, java.lang.String separator)
items
- Object[]separator
- Stringpublic static java.lang.String[] getEmptyStrings()
Copyright © 2002–2018 PMD. All rights reserved.