|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.sdm.quasar.client.core.common.util.StringUtilities
A helper class with some static methods with string operations.
| Field Summary | |
static java.lang.String |
DEFAULT_SEPARATORS
The default separators for words. |
static int |
LEFT_ALIGNMENT
Alignment constant for strings: left alignment. |
static int |
RIGHT_ALIGNMENT
Alignment constant for strings: right alignment. |
| Method Summary | |
static java.lang.String |
checkLength(java.lang.String str,
int len,
java.lang.String argname)
Checks the length of a string argument. |
static java.lang.String |
convertCamelCaseName(java.lang.String name,
int letter_case,
java.lang.String separator,
int leading_separator)
Converts a CamelCase-name to a name with separators. |
static java.lang.String |
cutString(java.lang.String text,
int max_length,
java.lang.String cutted_marker)
Cuts the given text String, so that it is at maximum
max_length characters long. |
static java.lang.String |
extractCVSRevision(java.lang.String revision)
Extracts the cvs-revision out of the given string. |
static java.lang.String |
extractFirstFewWords(java.lang.String text,
int max_length,
boolean use_first_line_only,
java.lang.String append_if_cutted)
Extracts the first few words (of the first line) of a (multiline) text. |
static java.lang.String |
fillToFixed(int number,
int length)
Returns a String, that contains the given number in
decimal notation right-bound in the fixed length-string, filled
up with zeros ('0'). |
static java.lang.String |
fillToFixed(long number,
int length)
Returns a String, that contains the given number in
decimal notation right-bound in the fixed length-string, filled
up with zeros ('0'). |
static java.lang.String |
fillToFixed(java.lang.String str,
int len)
Returns a String of a fixed length containing the original
string filled with spaces, where the original string is left aligned. |
static java.lang.String |
fillToFixed(java.lang.String str,
int len,
char fillchar,
int alignment)
Returns a String of a fixed length containing the original
string filled with given filling characters, where the original string is
aligned as specified. |
static java.lang.String |
fillToFixed(java.lang.String str,
int len,
int alignment)
Returns a String of a fixed length containing the original
string filled with spaces, where the original string is
aligned as specified. |
static java.lang.String |
fillToFixedHex(int number,
int length)
Returns a String, that contains the given number in
hexadecimal notation right-bound in the fixed length-string, filled
up with zeros ('0'). |
static java.lang.String |
fillToFixedHex(long number,
int length)
Returns a String, that contains the given number in
hexadecimal notation right-bound in the fixed length-string, filled
up with zeros ('0'). |
static int[] |
findNextVariable(java.lang.String string,
int start_index,
java.lang.String variable_prefix,
java.lang.String variable_postfix,
java.lang.String param_separators,
java.lang.String[] variable_name)
Finds the next variable in the string. |
static int |
findOutsideBraces(java.lang.String string,
int index,
java.lang.String stop_chars,
char brace_in_char,
char brace_out_char,
char quote_esc)
Finds any of the stop characters in the given string starting at a given index, which are not quoted |
static int |
findOutsideQuotes(java.lang.String string,
int index,
java.lang.String stop_chars,
char quote_char,
char quote_esc)
Finds any of the stop characters in the given string starting at a given index, which are not quoted |
static java.lang.String |
format(java.lang.String pattern,
java.lang.Object argument1)
Formats the given pattern using the arguments given. |
static java.lang.String |
format(java.lang.String pattern,
java.lang.Object[] arguments)
Formats the given pattern using the arguments given. |
static java.lang.String |
format(java.lang.String pattern,
java.lang.Object argument1,
java.lang.Object argument2)
Formats the given pattern using the arguments given. |
static java.lang.String |
format(java.lang.String pattern,
java.lang.Object argument1,
java.lang.Object argument2,
java.lang.Object argument3)
Formats the given pattern using the arguments given. |
static java.lang.String |
format(java.lang.String pattern,
java.lang.Object argument1,
java.lang.Object argument2,
java.lang.Object argument3,
java.lang.Object argument4)
Formats the given pattern using the arguments given. |
static java.lang.String |
getClassName(java.lang.Class cls)
Returns the class name only (without the package name) of the given Class. |
static java.lang.String |
getHTMLLabelString(java.lang.String label_text)
Returns a Swing-style html-text for the given label text with line breaks. |
static int |
getWordEndIndex(java.lang.String string,
int offset,
java.lang.String seperators,
boolean forward)
Returns the index of the first character after the word in the string at the given offset. |
static int |
getWordStartIndex(java.lang.String string,
int offset,
java.lang.String seperators,
boolean forward)
Returns the index of the first character of the next word in the string at the given offset. |
static int |
hexCharToInt(char hex_char)
Converts the given hexadecimal character into it's numeric value. |
static java.lang.String |
ident(java.lang.String source,
java.lang.String ident,
boolean ident_first)
Idents the given source string with the identation string. |
static java.lang.String |
mformat(java.lang.String pattern,
java.util.HashMap arguments)
Formats the given pattern using the arguments given. |
static java.lang.String |
mformat(java.lang.String pattern,
java.util.Map arguments)
Formats the given pattern using the arguments given. |
static java.lang.String |
mformat(java.lang.String pattern,
java.lang.String name1,
java.lang.Object argument1)
Formats the given pattern using the arguments given. |
static java.lang.String |
mformat(java.lang.String pattern,
java.lang.String name1,
java.lang.Object argument1,
java.lang.String name2,
java.lang.Object argument2)
Formats the given pattern using the arguments given. |
static java.lang.String |
mformat(java.lang.String pattern,
java.lang.String name1,
java.lang.Object argument1,
java.lang.String name2,
java.lang.Object argument2,
java.lang.String name3,
java.lang.Object argument3)
Formats the given pattern using the arguments given. |
static java.lang.String |
mformat(java.lang.String pattern,
java.lang.String name1,
java.lang.Object argument1,
java.lang.String name2,
java.lang.Object argument2,
java.lang.String name3,
java.lang.Object argument3,
java.lang.String name4,
java.lang.Object argument4)
Formats the given pattern using the arguments given. |
static java.lang.String |
mformat(java.lang.String pattern,
java.lang.String name1,
java.lang.Object argument1,
java.lang.String name2,
java.lang.Object argument2,
java.lang.String name3,
java.lang.Object argument3,
java.lang.String name4,
java.lang.Object argument4,
java.lang.String name5,
java.lang.Object argument5)
Formats the given pattern using the arguments given. |
static int |
nextTokenPos(java.lang.String str,
int idx,
java.lang.String delemiters,
char quotechar,
char escchar,
java.lang.String openbraces,
java.lang.String closebraces)
Parses the given String starting at the given index until a
delimiter character occures, but not withing a quotet text or within
braces. |
static int |
nextTokenPos(java.lang.String str,
int idx,
java.lang.String delemiters,
java.lang.String openbraces,
java.lang.String closebraces)
Parses the given String starting at the given index until a delimiter
character occures, but not withing a quotet text or within braces.
|
static int |
occurrencesOf(java.lang.String wholeString,
java.lang.String searchString)
How often does the search string occur in the whole string? |
static java.lang.String |
quoteString(java.lang.String str)
Quotes the string. |
static java.lang.String |
quoteString(java.lang.String str,
char qchar,
char escchar)
Quotes the string with the given quoting char. |
static java.lang.String |
quoteString(java.lang.String str,
char qchar,
char escchar,
boolean start_end_with_qchar,
boolean escape_escchar)
Quotes the string with the given quoting char. |
static java.lang.String[] |
readList(java.lang.String string,
java.lang.String seperators)
Converts the given string that contains a list of elements separated by any of the characters in the given separator string. |
static java.lang.String |
readNameValueParameters(java.lang.String string,
char param_eq,
java.lang.String param_seps,
char quote_char,
char quote_esc,
java.util.Map params)
Decodes a string as name-value pairs, where values can be quoted. |
static java.lang.String |
removeChar(java.lang.String str,
char removeChar)
Removes the given char from the given string. |
static java.lang.String |
removeSpaces(java.lang.String str)
Removes the given char from the given string. |
static java.lang.String |
replace(java.lang.String string,
java.lang.String search,
java.lang.String replace)
Replaces the search string with the replace string within the given string. |
static java.lang.String |
replaceAll(java.lang.String string,
java.lang.String quote_start,
java.lang.String quote_end,
java.lang.String[] variables,
java.lang.String[] replacements,
boolean leave_quotes)
Replaces in the given source String all occurences of variables
quoted with quote_start and quote_end with the strings in
replacements (may be leaving or removing quotes. |
static java.lang.String |
trim(java.lang.String string,
boolean start,
boolean end)
Trims the string like String.trim(), but with selection, if
whitespaces should be removed from start and / or the end of the string. |
static java.lang.String |
unquoteString(java.lang.String str)
Unquotes the string using a quoting char (') and escape char (\). |
static java.lang.String |
unquoteString(java.lang.String str,
char qchar,
char escchar)
Unquotes the string using the given quoting char and escape char. |
static java.lang.String |
unquoteURLName(java.lang.String escaped_path)
Decodes url-encoded name, which has '%'-escaped characters and returns it as normal string. |
static java.lang.String |
wrapString(java.lang.String input_string,
int max_char_count,
boolean wrapStyleWord,
boolean keepOriginalLineWraps)
Wraps the input string according to the given parameters |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String DEFAULT_SEPARATORS
public static final int LEFT_ALIGNMENT
public static final int RIGHT_ALIGNMENT
| Method Detail |
public static java.lang.String checkLength(java.lang.String str,
int len,
java.lang.String argname)
str - the string to checklen - the maximum length of the stringargname - the argument name (for error details)
java.lang.IllegalArgumentException - if the
string is null or superceeds the given length
public static java.lang.String fillToFixed(int number,
int length)
String, that contains the given number in
decimal notation right-bound in the fixed length-string, filled
up with zeros ('0').
number - the number to convert to a fixed-length stringlength - the length of the result string
public static java.lang.String fillToFixed(long number,
int length)
String, that contains the given number in
decimal notation right-bound in the fixed length-string, filled
up with zeros ('0').
number - the number to convert to a fixed-length stringlength - the length of the result string
public static java.lang.String fillToFixed(java.lang.String str,
int len)
String of a fixed length containing the original
string filled with spaces, where the original string is left aligned.
str - the originial Stringlen - the length of the result string
public static java.lang.String fillToFixed(java.lang.String str,
int len,
char fillchar,
int alignment)
String of a fixed length containing the original
string filled with given filling characters, where the original string is
aligned as specified.
str - the originial Stringlen - the length of the result stringfillchar - the character used for filling the empty spacealignment - the alignment of the original string (one of
{LEFT_ALIGNMENT, RIGHT_ALIGNMENT})
public static java.lang.String fillToFixed(java.lang.String str,
int len,
int alignment)
String of a fixed length containing the original
string filled with spaces, where the original string is
aligned as specified.
str - the originial Stringlen - the length of the result stringalignment - the alignment of the original string (one of
{LEFT_ALIGNMENT, RIGHT_ALIGNMENT})
public static java.lang.String fillToFixedHex(int number,
int length)
String, that contains the given number in
hexadecimal notation right-bound in the fixed length-string, filled
up with zeros ('0').
number - the number to convert to a fixed-length stringlength - the length of the result string
public static java.lang.String fillToFixedHex(long number,
int length)
String, that contains the given number in
hexadecimal notation right-bound in the fixed length-string, filled
up with zeros ('0').
number - the number to convert to a fixed-length stringlength - the length of the result string
public static java.lang.String trim(java.lang.String string,
boolean start,
boolean end)
String.trim(), but with selection, if
whitespaces should be removed from start and / or the end of the string.
string - the String to be trimmedstart - if true, removes whitespaces from the beginningend - if true, removes whitespaces from the end
public static int nextTokenPos(java.lang.String str,
int idx,
java.lang.String delemiters,
char quotechar,
char escchar,
java.lang.String openbraces,
java.lang.String closebraces)
String starting at the given index until a
delimiter character occures, but not withing a quotet text or within
braces. If the token starts with a delimiter character, this delimiter will
be returned as a token, which means the next character position will be
returned.
str - the Stringto parseidx - the start indexdelemiters - a Stringcontaining all delemiter charactersquotechar - the quoting characterescchar - the escape characteropenbraces - a Stringcontaining all open-braces charactersclosebraces - a Stringcontaining all closing-braces
characters
public static int nextTokenPos(java.lang.String str,
int idx,
java.lang.String delemiters,
java.lang.String openbraces,
java.lang.String closebraces)
String starting at the given index until a delimiter
character occures, but not withing a quotet text or within braces.
If the token starts with a delimiter character, this delimiter will be returned
as a token, which means the next character position will be returned.
str - the String to parseidx - the start indexdelemiters - a String containing all delemiter charactersopenbraces - a String containing all open-braces charactersclosebraces - a String containing all closing-braces characters
public static int occurrencesOf(java.lang.String wholeString,
java.lang.String searchString)
wholeString - The string that may contain the search stringsearchString - The string to be searched forpublic static java.lang.String quoteString(java.lang.String str)
String
starts and ends with the quoting char (') but marks every occurence of the
quoting char inside the original string with the escape char (\).
str - the original String
String
public static java.lang.String quoteString(java.lang.String str,
char qchar,
char escchar)
String
starts and ends with the quoting char but marks every occurence of the
quoting char inside the original string with the escape char (as prefix).
str - the original Stringqchar - the quoting characterescchar - the escape character
String
public static java.lang.String quoteString(java.lang.String str,
char qchar,
char escchar,
boolean start_end_with_qchar,
boolean escape_escchar)
String
starts and ends with the quoting char (if start_end_with_qchar==true)
but marks every occurence of the quoting char inside the original string
with the escape char (as prefix).
str - the original Stringqchar - the quoting characterescchar - the escape characterstart_end_with_qchar - if true, the string will start end end
with the qcharescape_escchar - if true, occurences of escchar in the
source string will be escaped with that char too
String
public static java.lang.String removeChar(java.lang.String str,
char removeChar)
str - the StringremoveChar - the character to remove from str
public static java.lang.String removeSpaces(java.lang.String str)
str - the String
public static java.lang.String unquoteString(java.lang.String str)
quoteString(java.lang.String).
str - the quoted String
String
public static java.lang.String unquoteString(java.lang.String str,
char qchar,
char escchar)
quoteString(java.lang.String).
str - the quoted Stringqchar - the quoting characterescchar - the escape character
Stringpublic static java.lang.String getClassName(java.lang.Class cls)
Class.
cls - the Class to extract class name of
public static java.lang.String getHTMLLabelString(java.lang.String label_text)
label_text - the label text
public static java.lang.String wrapString(java.lang.String input_string,
int max_char_count,
boolean wrapStyleWord,
boolean keepOriginalLineWraps)
input_string - the input stringmax_char_count - maximum characters per line (incl. space)wrapStyleWord - true: whole words won't be wrapped
false: wrapping can occur within a wordkeepOriginalLineWraps - true: original wrapping will be kept (\n)
false: original wrapping will be ignored
public static java.lang.String extractCVSRevision(java.lang.String revision)
revision - the string containing a CVS-revision
public static java.lang.String extractFirstFewWords(java.lang.String text,
int max_length,
boolean use_first_line_only,
java.lang.String append_if_cutted)
text - the text to extract words from (not null)max_length - the maximum length of the excerpt lineuse_first_line_only - if true, uses only the first line
of the text, otherwise uses all of the text (without line breaksī)append_if_cutted - a String, that is appended, if the text
is cutted (may be null)
public static java.lang.String cutString(java.lang.String text,
int max_length,
java.lang.String cutted_marker)
text String, so that it is at maximum
max_length characters long. It does it the following way:
max_length, returns the text.cutted_marker is appended at the end of the cutted string.cutted_marked
is inserted there and the last few characters of the word are appended.
public static java.lang.String convertCamelCaseName(java.lang.String name,
int letter_case,
java.lang.String separator,
int leading_separator)
name - the name to convert written in CamelCase (parts devided by an
upper case starting letter)letter_case - the case of the converted name; -1 for
lower case, +1 for upper case and 0 for
unchanged.separator - the seprator string to put between the partsleading_separator - behaviour of a leading separator; -1,
if no leading separator should occure, +1 if a leading
separator should be added and 0 if a leading separator should
be set only, when the first letter is in upper case.
public static java.lang.String unquoteURLName(java.lang.String escaped_path)
escaped_path - the url-encoded name containing '%'-escaped characters
public static int hexCharToInt(char hex_char)
hex_char - the character to convert
public static java.lang.String replace(java.lang.String string,
java.lang.String search,
java.lang.String replace)
string - the string to replace occurences of the search stringsearch - the search stringreplace - the replace string
public static java.lang.String ident(java.lang.String source,
java.lang.String ident,
boolean ident_first)
source - the source stringident - the ident stringident_first - if true, the first line will also be idented
public static java.lang.String[] readList(java.lang.String string,
java.lang.String seperators)
string - the source stringseperators - the separating characters (if null uses default)
public static int getWordEndIndex(java.lang.String string,
int offset,
java.lang.String seperators,
boolean forward)
string - the string to get the end index of the word ofseperators - the separatorsforward - if true looks for the end of the word in
forward direction, otherwise looks for it backward
public static int getWordStartIndex(java.lang.String string,
int offset,
java.lang.String seperators,
boolean forward)
string - the string to get the start index of the next word ofseperators - the separatorsforward - if true looks for the start of the word in
forward direction, otherwise looks for it backward
public static java.lang.String readNameValueParameters(java.lang.String string,
char param_eq,
java.lang.String param_seps,
char quote_char,
char quote_esc,
java.util.Map params)
string - the string to parseparam_eq - the character that separates key from valuesparam_seps - the character that separates key-value pairsquote_char - the quoting characterquote_esc - the escape character for quoting characterparams - the map of parameters to fill
public static int findOutsideQuotes(java.lang.String string,
int index,
java.lang.String stop_chars,
char quote_char,
char quote_esc)
string - the string to look intoindex - the starting index to search forstop_chars - the stop characters looking forquote_char - the quoting characterquote_esc - the escape character for quoting character
-1 if no stop character was found
public static int findOutsideBraces(java.lang.String string,
int index,
java.lang.String stop_chars,
char brace_in_char,
char brace_out_char,
char quote_esc)
string - the string to look intoindex - the starting index to search forstop_chars - the stop characters looking forbrace_in_char - the character to open a bracebrace_out_char - the character to close a bracequote_esc - the escape character for quoting character
-1 if no stop character was found
public static java.lang.String replaceAll(java.lang.String string,
java.lang.String quote_start,
java.lang.String quote_end,
java.lang.String[] variables,
java.lang.String[] replacements,
boolean leave_quotes)
String all occurences of variables
quoted with quote_start and quote_end with the strings in
replacements (may be leaving or removing quotes.
string - the String to replace occurences ofquote_start - the start quoting stringquote_end - the end quoting stringvariables - the varibles array with the names to replacereplacements - the replacement string array with the strings to replace the
variable of the same index withleave_quotes - if true, the result string still contains the source
quotes around the replacement string
public static int[] findNextVariable(java.lang.String string,
int start_index,
java.lang.String variable_prefix,
java.lang.String variable_postfix,
java.lang.String param_separators,
java.lang.String[] variable_name)
String array.
string - the string to parsestart_index - the index to start fromvariable_prefix - the prefix of the variablevariable_postfix - the postfix of the variable (may be null)param_separators - the characters that separates the variable name from
possible parametersvariable_name - array to store the variable name into at index 0
(must have at least size 1)
0 is the starting
index of the found variable expression (or -1 if no variable
was found), element 1 is the index of the next character after
the parsed variable (or -1 if no variable found), element 2
is the index of the next character after the variable expression.
public static java.lang.String mformat(java.lang.String pattern,
java.util.Map arguments)
Strings.
The pattern is formatted like the Java-default MessageFormat-patterns,
but with clear-text-names instead of indexes.
pattern - the message pattern (not null)arguments - the message arguments (if null,
simply the pattern is returned)
java.lang.ClassCastException - if a name in the mapping is not a String
java.lang.IllegalArgumentException - if a name is
null or empty
public static java.lang.String mformat(java.lang.String pattern,
java.util.HashMap arguments)
Strings.
The pattern is formatted like the Java-default MessageFormat-patterns,
but with clear-text-names instead of indexes.
pattern - the message pattern (not null)arguments - the message arguments (if null,
simply the pattern is returned)
java.lang.ClassCastException - if a name in the mapping is not a String
java.lang.IllegalArgumentException - if a name is
null or empty
public static java.lang.String mformat(java.lang.String pattern,
java.lang.String name1,
java.lang.Object argument1)
Strings
pattern - the message pattern (not null)name1 - the 1st name variable to be replaced (not null)argument1 - the 1st argument variable for the corresponding name
java.lang.IllegalArgumentException - if a name is
null or empty
public static java.lang.String mformat(java.lang.String pattern,
java.lang.String name1,
java.lang.Object argument1,
java.lang.String name2,
java.lang.Object argument2)
Strings
pattern - the message pattern (not null)name1 - the 1st name variable to be replaced (not null)argument1 - the 1st argument variable for the corresponding namename2 - the 2nd name variable to be replaced (not null)argument2 - the 2nd argument variable for the corresponding name
java.lang.IllegalArgumentException - if a name is
null or empty
public static java.lang.String mformat(java.lang.String pattern,
java.lang.String name1,
java.lang.Object argument1,
java.lang.String name2,
java.lang.Object argument2,
java.lang.String name3,
java.lang.Object argument3)
Strings
pattern - the message pattern (not null)name1 - the 1st name variable to be replaced (not null)argument1 - the 1st argument variable for the corresponding namename2 - the 2nd name variable to be replaced (not null)argument2 - the 2nd argument variable for the corresponding namename3 - the 3rd name variable to be replaced (not null)argument3 - the 3rd argument variable for the corresponding name
java.lang.IllegalArgumentException - if a name is
null or empty
public static java.lang.String mformat(java.lang.String pattern,
java.lang.String name1,
java.lang.Object argument1,
java.lang.String name2,
java.lang.Object argument2,
java.lang.String name3,
java.lang.Object argument3,
java.lang.String name4,
java.lang.Object argument4)
Strings
pattern - the message pattern (not null)name1 - the 1st name variable to be replaced (not null)argument1 - the 1st argument variable for the corresponding namename2 - the 2nd name variable to be replaced (not null)argument2 - the 2nd argument variable for the corresponding namename3 - the 3rd name variable to be replaced (not null)argument3 - the 3rd argument variable for the corresponding namename4 - the 4th name variable to be replaced (not null)argument4 - the 4th argument variable for the corresponding name
java.lang.IllegalArgumentException - if a name is
null or empty
public static java.lang.String mformat(java.lang.String pattern,
java.lang.String name1,
java.lang.Object argument1,
java.lang.String name2,
java.lang.Object argument2,
java.lang.String name3,
java.lang.Object argument3,
java.lang.String name4,
java.lang.Object argument4,
java.lang.String name5,
java.lang.Object argument5)
Strings
pattern - the message pattern (not null)name1 - the 1st name variable to be replaced (not null)argument1 - the 1st argument variable for the corresponding namename2 - the 2nd name variable to be replaced (not null)argument2 - the 2nd argument variable for the corresponding namename3 - the 3rd name variable to be replaced (not null)argument3 - the 3rd argument variable for the corresponding namename4 - the 4th name variable to be replaced (not null)argument4 - the 4th argument variable for the corresponding namename5 - the 5th name variable to be replaced (not null)argument5 - the 5th argument variable for the corresponding name
java.lang.IllegalArgumentException - if a name is
null or empty
public static java.lang.String format(java.lang.String pattern,
java.lang.Object[] arguments)
pattern - the message patternarguments - the message arguments (if null,
simply the pattern is returned)
public static java.lang.String format(java.lang.String pattern,
java.lang.Object argument1)
public static java.lang.String format(java.lang.String pattern,
java.lang.Object argument1,
java.lang.Object argument2)
public static java.lang.String format(java.lang.String pattern,
java.lang.Object argument1,
java.lang.Object argument2,
java.lang.Object argument3)
public static java.lang.String format(java.lang.String pattern,
java.lang.Object argument1,
java.lang.Object argument2,
java.lang.Object argument3,
java.lang.Object argument4)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||