public class StringUtil
extends java.lang.Object
Constructor and Description |
---|
StringUtil() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
decodeAsciiHex(java.lang.String encodedData)
Decode a string that represents binary data encoded in
ASCII hex.
|
static java.lang.String |
encodeAsciiHex(byte[] data)
Encode an array of bytes as an ASCII-hex string.
|
static boolean |
endsWithIgnoreCase(java.lang.String string1,
java.lang.String string2)
Case insensitive version of startsWith
|
static boolean |
equalIgnoreCase(char c1,
char c2)
Do a case insensitive comparison of characters for equality
|
static java.util.Comparator |
getCaseIgnoreComparator() |
static java.util.Comparator |
getNumericStringComparator() |
static java.lang.String |
GUIDToString(byte[] binaryGUID)
Method to change from a binary GUID to canonical string representation.
|
static int |
indexOfIgnoreCase(java.lang.String string,
char ch)
Case insensitive version of indexOf
|
static int |
indexOfIgnoreCase(java.lang.String string,
char ch,
int fromIndex)
Case insensitive version of indexOf
|
static int |
indexOfIgnoreCase(java.lang.String string1,
java.lang.String string2)
Case insensitive version of indexOf
|
static int |
indexOfIgnoreCase(java.lang.String string1,
java.lang.String string2,
int fromIndex)
Case insensitive version of indexOf
|
static java.lang.String |
join(java.lang.String[] strings,
java.lang.String delimiter)
Join the elements of an array of
String s into a single string separated by a delimiter string. |
static java.util.List<java.lang.String> |
splitStringWithEscapedDelimiter(java.lang.String input,
char delimiter,
char escChar)
Split an input string into multiple substrings based on a delimiter.
|
static boolean |
startsWithIgnoreCase(java.lang.String string1,
java.lang.String string2)
Case insensitive version of startsWith
|
static byte[] |
stringToGUID(java.lang.String stringGUID)
Method to change from a binary GUID to canonical string representation.
|
static java.lang.String |
substring(java.lang.String string,
int start,
int length)
A different kind of substring the that provided by java.lang.String
|
static java.lang.String |
substringAfter(java.lang.String string1,
java.lang.String string2)
Get the substring that consists of the sequence characters in string1 that
occur after the string2 in string1
|
static java.lang.String |
substringAfterIgnoreCase(java.lang.String string1,
java.lang.String string2)
Get the substring that consists of the sequence characters in string1 that
occur after the string2 in string1 (ignoring case)
|
static java.lang.String |
substringBefore(java.lang.String string1,
java.lang.String string2)
Get the substring that consists of the sequence characters in string1 that
occur before the string2 in string1
|
static java.lang.String |
substringBeforeIgnoreCase(java.lang.String string1,
java.lang.String string2)
Get the substring that consists of the sequence characters in string1 that
occur before the string2 in string1 (ignoring case)
|
static java.lang.String |
toLowerCaseChars(java.lang.String string)
Convert all the characters in a string to lower case.
|
static java.lang.String |
toUpperCaseChars(java.lang.String string)
Convert all the characters in a string to upper case.
|
public static java.lang.String toUpperCaseChars(java.lang.String string)
string
- the string to convertpublic static java.lang.String toLowerCaseChars(java.lang.String string)
string
- the string to convertpublic static boolean equalIgnoreCase(char c1, char c2)
c1
- the first characterc2
- the second characterpublic static int indexOfIgnoreCase(java.lang.String string, char ch)
string
- a string.ch
- a character.-1
if the character does not occur.public static int indexOfIgnoreCase(java.lang.String string, char ch, int fromIndex)
string
- a string.ch
- a character.fromIndex
- the index to start the search from.-1
if the character does not occur.public static int indexOfIgnoreCase(java.lang.String string1, java.lang.String string2)
string1
- a string.string2
- a string.-1
is returned.public static int indexOfIgnoreCase(java.lang.String string1, java.lang.String string2, int fromIndex)
string1
- a string.string2
- a string.fromIndex
- the index from which to start the search.-1
is returned.public static boolean startsWithIgnoreCase(java.lang.String string1, java.lang.String string2)
string1
- a string.string2
- a string.public static boolean endsWithIgnoreCase(java.lang.String string1, java.lang.String string2)
string1
- a string.string2
- a string.public static java.lang.String substring(java.lang.String string, int start, int length)
string
- a string.start
- the starting index of the substring;
if negative then it becomes string.length() + index;
if still negative then 0 is usedlength
- the length of the string to get;
if greater than what is available, only what is available is gotten
if negative then it is length of string + 1 + length, or 0 whichever is greaterpublic static java.lang.String substringBefore(java.lang.String string1, java.lang.String string2)
string1
- a stringstring2
- a stringpublic static java.lang.String substringBeforeIgnoreCase(java.lang.String string1, java.lang.String string2)
string1
- a stringstring2
- a stringpublic static java.lang.String substringAfter(java.lang.String string1, java.lang.String string2)
string1
- a stringstring2
- a stringpublic static java.lang.String substringAfterIgnoreCase(java.lang.String string1, java.lang.String string2)
string1
- a stringstring2
- a stringpublic static java.util.Comparator getCaseIgnoreComparator()
public static java.util.Comparator getNumericStringComparator()
public static java.lang.String GUIDToString(byte[] binaryGUID)
We do this so that the association value is more human-readable as it appears in the directory.
binaryGUID
- The binary GUIDpublic static byte[] stringToGUID(java.lang.String stringGUID)
We do this so that the association value is more human-readable as it appears in the directory.
stringGUID
- The string GUIDpublic static byte[] decodeAsciiHex(java.lang.String encodedData)
encodedData
- The encoded data stringpublic static java.lang.String encodeAsciiHex(byte[] data)
data
- The data to be encoded.public static java.lang.String join(java.lang.String[] strings, java.lang.String delimiter)
String
s into a single string separated by a delimiter string.strings
- an array of stringsdelimiter
- the delimiter stringpublic static java.util.List<java.lang.String> splitStringWithEscapedDelimiter(java.lang.String input, char delimiter, char escChar)
input
- the input stringdelimiter
- the delimiter that will be used to split the stringescChar
- the escape character that can be used to escape the delimiter in the input stringList
containing the split strings