public class StringUtil
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String[] |
EMPTY_STRINGS |
| Constructor and Description |
|---|
StringUtil() |
| Modifier and Type | Method and Description |
|---|---|
static void |
appendXmlEscaped(java.lang.StringBuffer buf,
java.lang.String src)
Appends to a StringBuffer the String src where non-ASCII and
XML special chars are escaped.
|
static void |
asStringOn(java.lang.StringBuffer sb,
java.util.Iterator iter,
java.lang.String separator)
Copies the elements returned by the iterator onto the string buffer
each delimited by the separator.
|
static java.lang.String |
htmlEncode(java.lang.String string) |
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)
Left pads a string.
|
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 |
replaceString(java.lang.String original,
char oldChar,
java.lang.String newString) |
static java.lang.String |
replaceString(java.lang.String original,
java.lang.String oldString,
java.lang.String newString) |
static java.lang.String[] |
substringsOf(java.lang.String source,
char delimiter)
Parses the input source using the delimiter specified.
|
static java.lang.String[] |
substringsOf(java.lang.String str,
java.lang.String separator)
Much more efficient than StringTokenizer.
|
static java.lang.String[] |
trimStartOn(java.lang.String[] strings,
int trimDepth)
Trims off the leading characters off the strings up to the trimDepth
specified.
|
public static java.lang.String replaceString(java.lang.String original,
char oldChar,
java.lang.String newString)
public static java.lang.String replaceString(java.lang.String original,
java.lang.String oldString,
java.lang.String newString)
public static void appendXmlEscaped(java.lang.StringBuffer buf,
java.lang.String src)
buf - The destination XML streamsrc - The String to append to the streampublic static java.lang.String htmlEncode(java.lang.String string)
public static java.lang.String[] substringsOf(java.lang.String source,
char delimiter)
source - Stringdelimiter - charpublic static java.lang.String[] substringsOf(java.lang.String str,
java.lang.String separator)
str - Stringseparator - charpublic static void asStringOn(java.lang.StringBuffer sb,
java.util.Iterator iter,
java.lang.String separator)
sb - StringBufferiter - Iteratorseparator - Stringpublic static int lengthOfShortestIn(java.lang.String[] strings)
strings - String[]public static int maxCommonLeadingWhitespaceForAll(java.lang.String[] strings)
strings - String[]public static java.lang.String[] trimStartOn(java.lang.String[] strings,
int trimDepth)
strings - trimDepth - public static java.lang.String lpad(java.lang.String s,
int length)
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.