Class StringUtil
java.lang.Object
org.hsqldb.lib.StringUtil
Provides a collection of convenience methods for processing and
creating objects with
String value components.- Since:
- 1.7.0
- Author:
- Campbell Burnet (campbell-burnet@users dot sourceforge.net), Fred Toussi (fredt@users dot sourceforge.net)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringarrayToString(Object array) Builds a bracketed CSV list from the arraystatic StringBuilds a CSV list from the specified int[], separator String and quote String.static Stringstatic StringBuilds a CSV list from the specified String[][], separator string and quote string.static StringBuilds a CSV list from the specified String[], separator string and quote string.static booleanChecks if text is empty (characters <= space)static intReturns the size of substring that does not contain any trailing spacesstatic intskipSpaces(String s, int start) Skips any spaces at or after start and returns the index of first non-space character;static String[]Splits the string into an array, using the separator.static StringtoLowerSubset(String source, char substitute) Returns a string with non-alphanumeric chars converted to the substitute character.static StringtoPaddedString(String source, int length, char pad, boolean trailing) static StringtoPaddedString(String source, int length, String pad, boolean trailing) static StringtoZeroPaddedString(long value, int precision, int maxSize) If necessary, adds zeros to the beginning of a value so that the total length matches the given precision, otherwise trims the right digits.
-
Constructor Details
-
StringUtil
public StringUtil()
-
-
Method Details
-
toZeroPaddedString
If necessary, adds zeros to the beginning of a value so that the total length matches the given precision, otherwise trims the right digits. Then if maxSize is smaller than precision, trims the right digits to maxSize. Negative values are treated as positive- Parameters:
value- longprecision- intmaxSize- int- Returns:
- String
-
toPaddedString
-
toPaddedString
-
toLowerSubset
Returns a string with non-alphanumeric chars converted to the substitute character. A digit first character is also converted. By sqlbob@users- Parameters:
source- string to convertsubstitute- character to use- Returns:
- converted string
-
arrayToString
-
getList
Builds a CSV list from the specified String[], separator string and quote string.- All arguments are assumed to be non-null.
- Separates each list element with the value of the
separatorargument. - Prepends and appends each element with the value of the
quoteargument. - No attempt is made to escape the quote character sequence if it is found internal to a list element.
- Parameters:
s- array ofStringobjectsseparator- theStringto use as the list element separatorquote- theStringwith which to quote the list elements- Returns:
- a CSV list
-
getList
Builds a CSV list from the specified int[], separator String and quote String.- All arguments are assumed to be non-null.
- Separates each list element with the value of the
separatorargument. - Prepends and appends each element with the value of the
quoteargument.
- Parameters:
s- the array of int valuesseparator- theStringto use as the separatorquote- theStringwith which to quote the list elements- Returns:
- a CSV list
-
getList
-
getList
Builds a CSV list from the specified String[][], separator string and quote string.- All arguments are assumed to be non-null.
- Uses only the first element in each subarray.
- Separates each list element with the value of the
separatorargument. - Prepends and appends each element with the value of the
quoteargument. - No attempt is made to escape the quote character sequence if it is found internal to a list element.
- Parameters:
s- the array ofStringarray objectsseparator- theStringto use as the list element separatorquote- theStringwith which to quote the list elements- Returns:
- a CSV list
-
isEmpty
Checks if text is empty (characters <= space)- Parameters:
s- java.lang.String- Returns:
- boolean true if text is null or empty, false otherwise
-
rightTrimSize
Returns the size of substring that does not contain any trailing spaces- Parameters:
s- the string- Returns:
- trimmed size
-
skipSpaces
Skips any spaces at or after start and returns the index of first non-space character;- Parameters:
s- the stringstart- index to start- Returns:
- index of first non-space
-
split
-