| java.lang.Object com.tc.util.StringUtil
StringUtil | public class StringUtil (Code) | | String utility methods.
|
Method Summary | |
final public static String | getNonNull(String s, String nullToken) For a string s, if non-null return s, else return nullToken. | final public static String | getNonNull(String s) Get a non-null version of the String. | public static String | indentLines(String source) Indent lines using a single tab by inserting them into source
after line breaks and returning a new String. | public static String | indentLines(String source, int indentLevel) Indent lines using tabs by inserting them into source
after line breaks and returning a new String. | public static StringBuffer | indentLines(StringBuffer source, int indentLevel) Indent lines using tabs by inserting them into source and returning source. | public static StringBuffer | indentLines(StringBuffer source, int indentLevel, char indentChar) Indent lines in the StringBuffer (line breaks found at \n) with indentChar repeated
indentLevel times. | public static int | indexOfStringBuffer(StringBuffer source, String search, int start) Find index of "search" in "source", starting at "start" index. | final public static String | reduce(String source) Reduces the size that a string occupies to the minimal possible by
ensuring that the back-end char array contains exactly the characters that
are needed, and no more. | final public static String | replaceAll(String source, String search, String replace, boolean skipQuotedStrings) Simple search/replace for non-pattern strings. | final public static String | safeToString(Object object) Normal toString(), but convert null to the
StringUtil.NULL_STRING . | final public static String | toPaddedString(long value, int radix, int paddedWidth) Format value to string using radix, then prepend with 0's out to paddedWidth. | final public static String | toString(Object[] objs, String separator, String prefix, String postfix) Creates a String representation of an array of objects by calling toString on each one. | final public static String | toString(Object[] objs) Helper method to convert object array [a, b, c] to comma-separated string "a, b, c". |
EMPTY | final public static String EMPTY(Code) | | The empty string
|
NULL_STRING | final public static String NULL_STRING(Code) | | A string representing a null value: ""
|
SPACE | final public static char SPACE(Code) | | A space character
|
SPACE_STRING | final public static String SPACE_STRING(Code) | | A space string
|
getNonNull | final public static String getNonNull(String s, String nullToken)(Code) | | For a string s, if non-null return s, else return nullToken.
Parameters: s - The starting string Parameters: nullToken - The null token s or nullToken depending on s |
getNonNull | final public static String getNonNull(String s)(Code) | | Get a non-null version of the String.
Parameters: s - The string Either s or the empty string if s was null |
indentLines | public static String indentLines(String source)(Code) | | Indent lines using a single tab by inserting them into source
after line breaks and returning a new String.
Parameters: source - Source string, may NOT be null New string, updated with indents throws: NullPointerException - If source is null |
indentLines | public static String indentLines(String source, int indentLevel)(Code) | | Indent lines using tabs by inserting them into source
after line breaks and returning a new String.
Parameters: source - Source string, may NOT be null Parameters: indentLevel - Number of tabs to insert, must be >= 0 Original buffer, updated throws: IllegalArgumentException - If indentLevel < 0 throws: NullPointerException - If source is null |
indentLines | public static StringBuffer indentLines(StringBuffer source, int indentLevel)(Code) | | Indent lines using tabs by inserting them into source and returning source.
Parameters: source - Source buffer, may be null Parameters: indentLevel - Number of tabs to insert, must be >= 0 Original buffer, updated throws: IllegalArgumentException - If indentLevel < 0 |
indentLines | public static StringBuffer indentLines(StringBuffer source, int indentLevel, char indentChar)(Code) | | Indent lines in the StringBuffer (line breaks found at \n) with indentChar repeated
indentLevel times.
Parameters: source - Source buffer, may be null Parameters: indentLevel - Number of chars to indent, must be >= 0 Parameters: indentChar - Indent character (usually ' ' or '\t') Original buffer, updated throws: IllegalArgumentException - If indentLevel < 0 |
indexOfStringBuffer | public static int indexOfStringBuffer(StringBuffer source, String search, int start)(Code) | | Find index of "search" in "source", starting at "start" index.
Parameters: source - Source buffer, must be non-null Parameters: search - Search string, must be non-null Parameters: start - Start index, should be 0<=startthrows: NullPointerException - If source or search is null |
reduce | final public static String reduce(String source)(Code) | | Reduces the size that a string occupies to the minimal possible by
ensuring that the back-end char array contains exactly the characters that
are needed, and no more.
Note that this method doesn't modify the original string as they are
immutable, a new string is returned instead.
Parameters: source - the string that needs to be reduced the reduced string, null if source is null |
replaceAll | final public static String replaceAll(String source, String search, String replace, boolean skipQuotedStrings)(Code) | | Simple search/replace for non-pattern strings. optionally skipping over quoted strings.
Parameters: source - the original string to perform the search/replace on, a modified version of this is returned, if nullthen null will be returned immediately Parameters: search - the string to search for in source , if null then null is returned immediately Parameters: replace - the string to replace search occurrences in source , if null then thesearch string is simply removed from source and not replaced with anything Parameters: skipQuotedStrings - if true then quoted strings will be skipped over a modified version of source , or null if source or search arenull |
toPaddedString | final public static String toPaddedString(long value, int radix, int paddedWidth)(Code) | | Format value to string using radix, then prepend with 0's out to paddedWidth.
If the formatted value is > paddedWidth, then the value is returned.
Parameters: value - Long value, must be >= 0 Parameters: radix - The radix to use when representing the value Parameters: paddedWidth - The width to pad to by prepending 0 Padded formatted string value for the long value, never null |
toString | final public static String toString(Object[] objs, String separator, String prefix, String postfix)(Code) | | Creates a String representation of an array of objects by calling toString on each one. Formatting
is controlled by the parameters.
Parameters: objs - (required) the array of objects to display Parameters: separator - (optional) a string to place between each object Parameters: prefix - (optional) a string to prefix each object with Parameters: postfix - (optional) a string to append to each object a String representation of the array, never returns null |
toString | final public static String toString(Object[] objs)(Code) | | Helper method to convert object array [a, b, c] to comma-separated string "a, b, c".
Parameters: objs - Array of objects, can be null String, never null |
|
|