|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
@ComponentSpecification public interface StringUtil
This is the interface for a collection of utility functions that help with
String handling and manipulation.
StringUtilImpl.getInstance(),
UnicodeUtil| Field Summary | |
|---|---|
static char[] |
EMPTY_CHAR_ARRAY
An empty char array. |
static String[] |
EMPTY_STRING_ARRAY
An empty String array. |
static String |
FALSE
a string representing the boolean value false |
static String |
LINE_SEPARATOR
The platform-specific line-separator string. |
static String |
LINE_SEPARATOR_CR
The line-separator with a single carriage-return. |
static String |
LINE_SEPARATOR_CRLF
The Windows line-separator (carriage-return line-feed). |
static String |
LINE_SEPARATOR_LF
The Unix line-separator (line-feed). |
static String |
LINE_SEPARATOR_LFCR
The Mac line-separator (line-feed carriage-return). |
static String |
TRUE
a string representing the boolean value true |
| Method Summary | |
|---|---|
String |
fromCamlCase(String string,
char separator)
This method converts the given string from caml-case syntax to
lower-case using the given separator as word-boundary. |
boolean |
isEmpty(String string)
This method determines if the given string contains no information. |
boolean |
isEmpty(String string,
boolean trim)
This method determines if the given string is empty. |
boolean |
isSubstring(char[] string,
String substring,
int offset)
This method checks if the given string
contains the given
substring at the given offset. |
boolean |
isSubstring(String string,
String substring,
int offset)
This method checks if the given string
contains the given
substring at the given offset. |
String |
padNumber(long number,
int digits)
This method formats a positive number to a string with at least the given number of digits padding it with leading zeros. |
String |
padNumber(long number,
int digits,
int radix)
This method formats a positive number to a string using the given radix with at least the given number of digits padding it with
leading zeros. |
Boolean |
parseBoolean(String booleanValue)
This method parses a boolean value given as string. |
void |
replace(char[] string,
char oldChar,
char newChar)
This method replaces all occurrences of oldChar in the
char-array given by string with newChar. |
String |
replace(String string,
String match,
String replace)
This method replaces all occurrences of the string match with
the string replace in the given string. |
String |
replaceSuffixWithCase(String string,
int suffixLength,
String newSuffixLowerCase)
This method delegates to replaceSuffixWithCase(String, int, String, Locale) using
Locale.ENGLISH. |
String |
replaceSuffixWithCase(String string,
int suffixLength,
String newSuffixLowerCase,
Locale locale)
This method replaces the last suffixLength number of
characters from string with the lower-case string
newSuffixLowerCase with respect to the original case of the
given string. |
String |
toCamlCase(String string)
This method converts the given string to caml-case syntax
using the default separators ' ', '-',
'_' and '.' |
String |
toCamlCase(String string,
char... separators)
This method converts the given string to caml-case syntax. |
| Field Detail |
|---|
static final String TRUE
true
static final String FALSE
false
static final String LINE_SEPARATOR
LINE_SEPARATOR_LF, LINE_SEPARATOR_CRLF,
LINE_SEPARATOR_LFCR, LINE_SEPARATOR_CR.
static final String LINE_SEPARATOR_CR
static final String LINE_SEPARATOR_LF
static final String LINE_SEPARATOR_CRLF
static final String LINE_SEPARATOR_LFCR
static final String[] EMPTY_STRING_ARRAY
String array.
static final char[] EMPTY_CHAR_ARRAY
| Method Detail |
|---|
Boolean parseBoolean(String booleanValue)
booleanValue - is the boolean value as string.
true if the given string
equals to
true, false if it
equals to
false and null in any other case.Boolean.valueOf(String)
void replace(char[] string,
char oldChar,
char newChar)
oldChar in the
char-array given by string with newChar.
string - is the char-array where the replacement should take place.oldChar - is the character to be replaced.newChar - is the replacement for oldChar.String.replace(char, char)
String replace(String string,
String match,
String replace)
match with
the string replace in the given string.
string - is the string where to replace.match - is the string that is searched and replaced.replace - is the string match is substituted with.
match
replaced by replace.
String replaceSuffixWithCase(String string,
int suffixLength,
String newSuffixLowerCase)
replaceSuffixWithCase(String, int, String, Locale) using
Locale.ENGLISH.
string - is the string to replace.suffixLength - is the length of the suffix from string to
replace.newSuffixLowerCase - is the new suffix for the given
string in lower-case.
string with the last
suffixLength characters cut off and replaced by
newSuffixLowerCase with respect to the original case
of string.replaceSuffixWithCase(String, int, String, Locale)
String replaceSuffixWithCase(String string,
int suffixLength,
String newSuffixLowerCase,
Locale locale)
suffixLength number of
characters from string with the lower-case string
newSuffixLowerCase with respect to the original case of the
given string.Locale.ENGLISH:string |
suffixLength |
newSuffixLowerCase |
|
|---|---|---|---|
| foobar | 3 | foo | foofoo |
| FOOBAR | 3 | foo | FOOFOO |
| FooBar | 3 | foo | FooFoo |
| FooBar | 2 | foo | FooBfoo |
string - is the string to replace.suffixLength - is the length of the suffix from string to
replace.newSuffixLowerCase - is the new suffix for the given
string in lower-case.locale - is the locale used for case transformation.
string with the last
suffixLength characters cut off and replaced by
newSuffixLowerCase with respect to the original case
of string.boolean isEmpty(String string)
string - is the string to check.
true if the given string is null or has a
trimmed length of zero, false otherwise.isEmpty(String, boolean)
boolean isEmpty(String string,
boolean trim)
string - is the string to check.trim - if whitespaces should be ignored and a string with a trimmed
length of zero is considered as empty.
true if the given string is null or has a
(trimmed) length of zero, false otherwise.
String padNumber(long number,
int digits)
padNumber(5, 3) will return "005"padNumber(25, 3) will return "025"padNumber(100, 3) will return "100"
number - is the positive number to format.digits - is the (minimum) number of digits required.
digits. If the number is less, leading zeros are
appended.
String padNumber(long number,
int digits,
int radix)
radix with at least the given number of digits padding it with
leading zeros.padNumber(31, 3, 16) will return "01f"padNumber(5, 6, 2) will return "000101"digits: | Radix | byte | short | int | long |
|---|---|---|---|---|
| 2 | 8 | 16 | 32 | 64 |
| 8 | 3 | 6 | 9 | 12 |
| 10 | 3 | 5 | 9 | 19 |
| 16 | 2 | 4 | 8 | 16 |
number - is the positive number to format.digits - is the (minimum) number of digits required.radix - is the radix to use.
digits. If the number is less, leading zeros are
appended.String toCamlCase(String string)
string to caml-case syntax
using the default separators ' ', '-',
'_' and '.'.
string - is the string to convert.
string in caml-case syntax.toCamlCase(String, char[])
String toCamlCase(String string,
char... separators)
string to caml-case syntax.string that are in the list given by
separators and capitalizes the first character of the
following word.| string | toCamlCase(string) |
|---|---|
foo bar |
fooBar |
aAa-bBB-CcC |
aAaBBBCcC |
X--m_._l.. |
XML |
string - is the string to convert.separators - is the list of characters that are treated as
word-separators.
string in caml-case syntax.
String fromCamlCase(String string,
char separator)
string from caml-case syntax to
lower-case using the given separator as word-boundary.| string | separator | fromCamlCase(string, separator) |
|---|---|---|
| FooBar | - | foo-bar |
| someWordMix | . | some.word.mix |
| AbbreviationsLikeXMLshouldNotBeCapitalized | _ | abbreviations_like_xmlshould_not_be_capitalized |
| FOO_BAR | * | foo_bar |
string - is the string to convert.separator - is the character to insert at word-boundaries indicated by
a switch from lower- to upper-case.
string in lower-case with the given
separator inserted at word-boundaries.toCamlCase(String, char...)
boolean isSubstring(String string,
String substring,
int offset)
string
contains the given
substring at the given offset.string.indexOf(substring, offset) == offsetor
string.substring(offset).beginsWith(substring)
string - is the string potentially containing substring.substring - is the substring that should be contained in
string at the given offset.offset - is the offset in string where to check for
substring.
true if the given string
contains the given
substring at the given offset and
false otherwise.
boolean isSubstring(char[] string,
String substring,
int offset)
string
contains the given
substring at the given offset.string.indexOf(substring, offset) == offsetor
string.substring(offset).beginsWith(substring)
string - is the char[] representing the string potentially containing
substring.substring - is the substring that should be contained in
string at the given offset.offset - is the offset in string where to check for
substring.
true if the given string
contains the given
substring at the given offset and
false otherwise.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||