StringUtils

Members

Functions

escapeJson
string escapeJson(string value)

Escape a json value string

Static functions

asciiToLowerCase
string asciiToLowerCase(string s)
Undocumented in source. Be warned that the author may not have intended to support it.
commaDelimitedListToStringArray
string[] commaDelimitedListToStringArray(string str)

Convert a comma delimited list (e.g., a row from a CSV file) into an array of strings. @param str the input {@code string} (potentially {@code null} or empty) @return an array of strings, or the empty array in case of empty input

deleteAny
string deleteAny(string inString, string charsToDelete)

Delete any character in a given {@code string}. @param inString the original {@code string} @param charsToDelete a set of characters to delete. E.g. "az\n" will delete 'a's, 'z's and new lines. @return the resulting {@code string}

delimitedListToStringArray
string[] delimitedListToStringArray(string str, string delimiter)

Take a {@code string} that is a delimited list and convert it into a {@code string} array. <p>A single {@code delimiter} may consist of more than one character, but it will still be considered as a single delimiter string, rather than as bunch of potential delimiter characters, in contrast to {@link #tokenizeToStringArray}. @param str the input {@code string} (potentially {@code null} or empty) @param delimiter the delimiter between elements (this is a single delimiter, rather than a bunch individual delimiter characters) @return an array of the tokens in the list @see #tokenizeToStringArray

delimitedListToStringArray
string[] delimitedListToStringArray(string str, string delimiter, string charsToDelete)

Take a {@code string} that is a delimited list and convert it into a {@code string} array. <p>A single {@code delimiter} may consist of more than one character, but it will still be considered as a single delimiter string, rather than as bunch of potential delimiter characters, in contrast to {@link #tokenizeToStringArray}. @param str the input {@code string} (potentially {@code null} or empty) @param delimiter the delimiter between elements (this is a single delimiter, rather than a bunch individual delimiter characters) @param charsToDelete a set of characters to delete; useful for deleting unwanted line breaks: e.g. "\r\n\f" will delete all new lines and line feeds in a {@code string} @return an array of the tokens in the list @see #tokenizeToStringArray

getBytes
byte[] getBytes(string s)
Undocumented in source. Be warned that the author may not have intended to support it.
getBytes
byte[] getBytes(string s, string charset)
Undocumented in source. Be warned that the author may not have intended to support it.
normalizeCharset
string normalizeCharset(string s)

Convert alternate charset names (eg utf8) to normalized name (eg UTF-8).

normalizeCharset
string normalizeCharset(string s, int offset, int length)

Convert alternate charset names (eg utf8) to normalized name (eg UTF-8).

randomId
string randomId(size_t n, string str)
Undocumented in source. Be warned that the author may not have intended to support it.
split
string[] split(string str)

<p> Splits the provided text into an array, using whitespace as the separator. Whitespace is defined by {@link Character#isWhitespace(char)}. </p> <p> <p> The separator is not included in the returned string array. Adjacent separators are treated as one separator. For more control over the split use the StrTokenizer class. </p> <p> <p> A <code>null</code> input string returns <code>null</code>. </p> <p> <pre> StringUtils.split(null) = null StringUtils.split("") = [] StringUtils.split("abc def") = ["abc", "def"] StringUtils.split("abc def") = ["abc", "def"] StringUtils.split(" abc ") = ["abc"] </pre>

split
string[] split(string str, string separatorChars)

<p> Splits the provided text into an array, separators specified. This is an alternative to using StringTokenizer. </p> <p> <p> The separator is not included in the returned string array. Adjacent separators are treated as one separator. For more control over the split use the StrTokenizer class. </p> <p> <p> A <code>null</code> input string returns <code>null</code>. A <code>null</code> separatorChars splits on whitespace. </p> <p> <pre> StringUtils.split(null, *) = null StringUtils.split("", *) = [] StringUtils.split("abc def", null) = ["abc", "def"] StringUtils.split("abc def", " ") = ["abc", "def"] StringUtils.split("abc def", " ") = ["abc", "def"] StringUtils.split("ab:cd:ef", ":") = ["ab", "cd", "ef"] </pre>

split
string[] split(string str, char separatorChar)

<p> Splits the provided text into an array, separator specified. This is an alternative to using StringTokenizer. </p> <p> <p> The separator is not included in the returned string array. Adjacent separators are treated as one separator. For more control over the split use the StrTokenizer class. </p> <p> <p> A <code>null</code> input string returns <code>null</code>. </p> <p> <pre> StringUtils.split(null, *) = null StringUtils.split("", *) = [] StringUtils.split("a.b.c", '.') = ["a", "b", "c"] StringUtils.split("a..b.c", '.') = ["a", "b", "c"] StringUtils.split("a:b:c", '.') = ["a:b:c"] StringUtils.split("a b c", ' ') = ["a", "b", "c"] </pre>

split
string[] split(string str, string separatorChars, int max)

<p> Splits the provided text into an array with a maximum length, separators specified. </p> <p> <p> The separator is not included in the returned string array. Adjacent separators are treated as one separator. </p> <p> <p> A <code>null</code> input string returns <code>null</code>. A <code>null</code> separatorChars splits on whitespace. </p> <p> <p> If more than <code>max</code> delimited substrings are found, the last returned string includes all characters after the first <code>max - 1</code> returned strings (including separator characters). </p> <p> <pre> StringUtils.split(null, *, *) = null StringUtils.split("", *, *) = [] StringUtils.split("ab de fg", null, 0) = ["ab", "cd", "ef"] StringUtils.split("ab de fg", null, 0) = ["ab", "cd", "ef"] StringUtils.split("ab:cd:ef", ":", 0) = ["ab", "cd", "ef"] StringUtils.split("ab:cd:ef", ":", 2) = ["ab", "cd:ef"] </pre>

toCommaDelimitedString
string toCommaDelimitedString(string[] arr)

Convert a {@code string} array into a comma delimited {@code string} (i.e., CSV). <p>Useful for {@code toString()} implementations. @param arr the array to display (potentially {@code null} or empty) @return the delimited {@code string}

toCommaDelimitedString
string toCommaDelimitedString(Object[] arr)
Undocumented in source. Be warned that the author may not have intended to support it.
toDelimitedString
string toDelimitedString(string[] arr, string delim)

Convert a {@code string} array into a delimited {@code string} (e.g. CSV). <p>Useful for {@code toString()} implementations. @param arr the array to display (potentially {@code null} or empty) @param delim the delimiter to use (typically a ",") @return the delimited {@code string}

toDelimitedString
string toDelimitedString(Object[] arr, string delim)
Undocumented in source. Be warned that the author may not have intended to support it.
toInt
int toInt(string str, int from)
Undocumented in source. Be warned that the author may not have intended to support it.
toStringArray
string[] toStringArray(InputRange!string range)

Copy the given Enumeration into a {@code string} array. The Enumeration must contain {@code string} elements only. @param enumeration the Enumeration to copy @return the {@code string} array

Variables

EMPTY
enum string EMPTY;
Undocumented in source.
EMPTY_STRING_ARRAY
enum string[] EMPTY_STRING_ARRAY;
Undocumented in source.
__ISO_8859_1
enum string __ISO_8859_1;
Undocumented in source.
__UTF16
enum string __UTF16;
Undocumented in source.
__UTF8
enum string __UTF8;
Undocumented in source.
lowercases
enum char[] lowercases;
Undocumented in source.

Meta