|
intarsys runtime library | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.intarsys.tools.string.StringTools
public class StringTools
A tool class for the handling of strings.
| Field Summary | |
|---|---|
static String |
CR
|
static String |
CRLF
|
static String |
DATEFORMAT_SIMPLE
|
static String |
EMPTY
An empty string constant |
static String |
FORMAT_D
|
static String |
FORMAT_F
|
static String |
FORMAT_I
|
static String |
FORMAT_P
|
static String |
FORMAT_S
|
static String |
LF
|
static String |
SPACE
An single space constant |
| Constructor Summary | |
|---|---|
StringTools()
|
|
| Method Summary | |
|---|---|
static String |
breakForced(String value,
int max,
String breakPattern)
|
static String |
capitalize(String text)
Capitalizes the first letter of the text. |
static void |
clear(char[] value)
clear character array content. |
static String |
format(Object value,
String format)
Create a string representation and format value according to
the instructions in format. |
static String |
getCommonPrefix(String a,
String b,
boolean ignoreCase)
|
static String |
getFirstLine(String text)
The first line of text (all characters up to the first occurrence of either "\n" or "\r". |
static String |
getLeading(String value,
int count)
|
static int |
getLineCount(String text)
The number of lines in text. |
static String |
getTrailing(String value,
int count)
|
static boolean |
isEmpty(char[] value)
true if value is "empty" in any respect. |
static boolean |
isEmpty(String value)
true if value is "empty" in any respect. |
static boolean |
isNumeric(String value)
true if value seems to be a numeric value. |
static String |
join(List<String> elements,
String separator)
Joins a List of Strings to a single one. |
static String |
join(String[] elements,
String separator)
Joins an array of Strings to a single one. |
static String |
padLeft(String value,
int count)
|
static String |
padRight(String value,
int count)
|
static String[] |
parseCommandline(String line)
Parse a commandline string with the default escape character. |
static String[] |
parseCommandline(String line,
char escape)
Parse a commandline string. |
static String |
pathAppend(String prefix,
String separator,
String name)
Create a new path from the concatenation of prefix and name. |
static String |
quote(String value)
|
static String |
safeString(Object object)
Create a string representation of object that is guaranteed
not to fail in any case. |
static byte[] |
toByteArray(String value)
Create a byte array from the string. |
static String |
toCamelCase(String value,
String allowed)
Convert value to camel case notation. |
static String |
toString(byte[] value)
Create a string from the byte array. |
static String |
trimAlphaNumeric(String value)
Create a string containing only the alphanumeric content of value. |
static String |
trimLeft(String value)
Create a new string from value without leading whitespace. |
static String |
trimRight(String value)
Create a new string from value without trailing whitespace. |
static String |
unquote(String value)
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String CR
public static final String CRLF
public static final String DATEFORMAT_SIMPLE
public static final String EMPTY
public static final String FORMAT_D
public static final String FORMAT_F
public static final String FORMAT_I
public static final String FORMAT_P
public static final String FORMAT_S
public static final String LF
public static final String SPACE
| Constructor Detail |
|---|
public StringTools()
| Method Detail |
|---|
public static String breakForced(String value,
int max,
String breakPattern)
public static String capitalize(String text)
text -
public static void clear(char[] value)
value - The value to be cleared
public static String format(Object value,
String format)
value according to
the instructions in format.
If value is null, the empty string is returned.
public static String getCommonPrefix(String a,
String b,
boolean ignoreCase)
public static String getFirstLine(String text)
text - The text where the first line is looked up.
public static String getLeading(String value,
int count)
public static int getLineCount(String text)
text. This is 1 + the number of "\n"
in text.
text - The text where the lines are counted.
text. This is 1 + the number
of "\n" in text.
public static String getTrailing(String value,
int count)
public static boolean isEmpty(char[] value)
true if value is "empty" in any respect.
This is the case when value == null, value has no characters or only whitespace.
value - The value to be inspected for emptyness.
true if value is "empty" in any
respect.public static boolean isEmpty(String value)
true if value is "empty" in any respect.
This is the case when value == null, value has no characters or only whitespace.
value - The value to be inspected for emptyness.
true if value is "empty" in any
respect.public static boolean isNumeric(String value)
true if value seems to be a numeric value. To
qualify only the first character is examined. value
qualifies as numeric if the first character is a digit, a "+", a "-" or a
".".
value -
true if value seems to be numeric.
public static String join(List<String> elements,
String separator)
separator.
elements - List of Stringsseparator - a String used as a separator between two elements, e.g. "\n"
for a new line. May be null.
public static String join(String[] elements,
String separator)
separator.
elements - array of Stringsseparator - a String used as a separator between two elements, e.g. "\n"
for a new line. May be null.
public static String padLeft(String value,
int count)
public static String padRight(String value,
int count)
public static String[] parseCommandline(String line)
line - The commandline string.
public static String[] parseCommandline(String line,
char escape)
line - The commandline string.
public static String pathAppend(String prefix,
String separator,
String name)
prefix - separator - name -
public static String quote(String value)
public static String safeString(Object object)
object that is guaranteed
not to fail in any case.
object - The object to be printed.
object that is
guaranteed not to fail in any case.public static byte[] toByteArray(String value)
If you use this, you should be sure you will encounter valid ascii characters only!
value -
public static String toCamelCase(String value,
String allowed)
value is tokenized at non alphanumeric characters, separator characters are ignored. all tokens are converted to lowercase and then for all tokens except the first the first character is uppercased.
The implementation tries to detect if value is already a camel case string and preserves it.
value -
public static String toString(byte[] value)
If you use this, you should be sure you will encounter valid ascii characters only!
value -
public static String trimAlphaNumeric(String value)
value.
value - The string to be trimmed.
value.public static String trimLeft(String value)
value without leading whitespace.
value - The string to be stripped.
value with leading whitespace stripped.public static String trimRight(String value)
value without trailing whitespace.
value - The string to be stripped.
value with trailing whitespace stripped.
public static String unquote(String value)
throws IOException
IOException
|
intarsys runtime library | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||