Top Description Constructors Methods
org.hsqldb.lib

public Class StringUtil

extends Object
Class Inheritance
Imports
java.lang.reflect.Array

Provides a collection of convenience methods for processing and creating objects with String value components.
Authors
Campbell Burnet (campbell-burnet@users dot sourceforge.net), Fred Toussi (fredt@users dot sourceforge.net)
Since
1.7.0
Version
2.7.3

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static String

Returns:

string
arrayToString
(Object
an array of Objects
array
)

Builds a bracketed CSV list from the array

public static String

Returns:

a CSV list
getList
(String[]
array of String objects
s
,
String
the String to use as the list element separator
separator
,
String
the String with which to quote the list elements
quote
)

Builds a CSV list from the specified String[], separator string and quote string.

public static String

Returns:

a CSV list
getList
(int[]
the array of int values
s
,
String
the String to use as the separator
separator
,
String
the String with which to quote the list elements
quote
)

Builds a CSV list from the specified int[], separator String and quote String.

public static String
getList(long[] s, String separator, String quote)

public static String

Returns:

a CSV list
getList
(String[][]
the array of String array objects
s
,
String
the String to use as the list element separator
separator
,
String
the String with which to quote the list elements
quote
)

Builds a CSV list from the specified String[][], separator string and quote string.

public static boolean

Returns:

boolean true if text is null or empty, false otherwise
isEmpty
(String
java.lang.String
s
)

Checks if text is empty (characters <= space)

public static int

Returns:

trimmed size
rightTrimSize
(String
the string
s
)

Returns the size of substring that does not contain any trailing spaces

public static int

Returns:

index of first non-space
skipSpaces
(String
the string
s
,
int
index to start
start
)

Skips any spaces at or after start and returns the index of first non-space character;

public static String[]

Returns:

array of strings
split
(String
the string
s
,
String
the separator
separator
)

Splits the string into an array, using the separator.

public static String

Returns:

converted string
toLowerSubset
(String
string to convert
source
,
char
character to use
substitute
)

Returns a string with non-alphanumeric chars converted to the substitute character.

public static String
toPaddedString(String source, int length, char pad, boolean trailing)

public static String
toPaddedString(String source, int length, String pad, boolean trailing)

public static String

Returns:

String
toZeroPaddedString
(long
long
value
,
int
int
precision
,
int
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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

StringUtilback to summary
public StringUtil()

Method Detail

arrayToStringback to summary
public static String arrayToString(Object array)

Builds a bracketed CSV list from the array

Parameters
array:Object

an array of Objects

Returns:String

string

getListback to summary
public static String getList(String[] s, String separator, String quote)

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 separator argument.
  • Prepends and appends each element with the value of the quote argument.
  • No attempt is made to escape the quote character sequence if it is found internal to a list element.
Parameters
s:String[]

array of String objects

separator:String

the String to use as the list element separator

quote:String

the String with which to quote the list elements

Returns:String

a CSV list

getListback to summary
public static String getList(int[] s, String separator, String quote)

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 separator argument.
  • Prepends and appends each element with the value of the quote argument.
Parameters
s:int[]

the array of int values

separator:String

the String to use as the separator

quote:String

the String with which to quote the list elements

Returns:String

a CSV list

getListback to summary
public static String getList(long[] s, String separator, String quote)
getListback to summary
public static String getList(String[][] s, String separator, String quote)

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 separator argument.
  • Prepends and appends each element with the value of the quote argument.
  • No attempt is made to escape the quote character sequence if it is found internal to a list element.
Parameters
s:String[][]

the array of String array objects

separator:String

the String to use as the list element separator

quote:String

the String with which to quote the list elements

Returns:String

a CSV list

isEmptyback to summary
public static boolean isEmpty(String s)

Checks if text is empty (characters <= space)

Parameters
s:String

java.lang.String

Returns:boolean

boolean true if text is null or empty, false otherwise

rightTrimSizeback to summary
public static int rightTrimSize(String s)

Returns the size of substring that does not contain any trailing spaces

Parameters
s:String

the string

Returns:int

trimmed size

skipSpacesback to summary
public static int skipSpaces(String s, int start)

Skips any spaces at or after start and returns the index of first non-space character;

Parameters
s:String

the string

start:int

index to start

Returns:int

index of first non-space

splitback to summary
public static String[] split(String s, String separator)

Splits the string into an array, using the separator. If separator is not found in the string, the whole string is returned in the array.

Parameters
s:String

the string

separator:String

the separator

Returns:String[]

array of strings

toLowerSubsetback to summary
public static String toLowerSubset(String source, char substitute)

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

string to convert

substitute:char

character to use

Returns:String

converted string

toPaddedStringback to summary
public static String toPaddedString(String source, int length, char pad, boolean trailing)
toPaddedStringback to summary
public static String toPaddedString(String source, int length, String pad, boolean trailing)
toZeroPaddedStringback to summary
public static String toZeroPaddedString(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. Then if maxSize is smaller than precision, trims the right digits to maxSize. Negative values are treated as positive

Parameters
value:long

long

precision:int

int

maxSize:int

int

Returns:String

String