com.sdm.quasar.client.core.common.util
Class StringUtilities

java.lang.Object
  extended bycom.sdm.quasar.client.core.common.util.StringUtilities

public class StringUtilities
extends java.lang.Object

A helper class with some static methods with string operations.

Author:
Thomas Wolf

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

DEFAULT_SEPARATORS

public static final java.lang.String DEFAULT_SEPARATORS
The default separators for words.

See Also:
Constant Field Values

LEFT_ALIGNMENT

public static final int LEFT_ALIGNMENT
Alignment constant for strings: left alignment.

See Also:
Constant Field Values

RIGHT_ALIGNMENT

public static final int RIGHT_ALIGNMENT
Alignment constant for strings: right alignment.

See Also:
Constant Field Values
Method Detail

checkLength

public static java.lang.String checkLength(java.lang.String str,
                                           int len,
                                           java.lang.String argname)
Checks the length of a string argument.

Parameters:
str - the string to check
len - the maximum length of the string
argname - the argument name (for error details)
Returns:
the string adjusted to the given length; left-aligned and filled up with spaces.
Throws:
java.lang.IllegalArgumentException - if the string is null or superceeds the given length

fillToFixed

public 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').

Parameters:
number - the number to convert to a fixed-length string
length - the length of the result string

fillToFixed

public 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').

Parameters:
number - the number to convert to a fixed-length string
length - the length of the result string

fillToFixed

public 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.

Parameters:
str - the originial String
len - the length of the result string

fillToFixed

public 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.

Parameters:
str - the originial String
len - the length of the result string
fillchar - the character used for filling the empty space
alignment - the alignment of the original string (one of {LEFT_ALIGNMENT, RIGHT_ALIGNMENT})

fillToFixed

public 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.

Parameters:
str - the originial String
len - the length of the result string
alignment - the alignment of the original string (one of {LEFT_ALIGNMENT, RIGHT_ALIGNMENT})

fillToFixedHex

public 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').

Parameters:
number - the number to convert to a fixed-length string
length - the length of the result string

fillToFixedHex

public 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').

Parameters:
number - the number to convert to a fixed-length string
length - the length of the result string

trim

public 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.

Parameters:
string - the String to be trimmed
start - if true, removes whitespaces from the beginning
end - if true, removes whitespaces from the end
Returns:
the string, with white space removed from the front and/or end.

nextTokenPos

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)
Parses the given 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.

Parameters:
str - the Stringto parse
idx - the start index
delemiters - a Stringcontaining all delemiter characters
quotechar - the quoting character
escchar - the escape character
openbraces - a Stringcontaining all open-braces characters
closebraces - a Stringcontaining all closing-braces characters
Returns:
the position of the next token

nextTokenPos

public 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. 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.

Parameters:
str - the String to parse
idx - the start index
delemiters - a String containing all delemiter characters
openbraces - a String containing all open-braces characters
closebraces - a String containing all closing-braces characters
Returns:
the position of the next token

occurrencesOf

public static int occurrencesOf(java.lang.String wholeString,
                                java.lang.String searchString)
How often does the search string occur in the whole string?

Parameters:
wholeString - The string that may contain the search string
searchString - The string to be searched for

quoteString

public static java.lang.String quoteString(java.lang.String str)
Quotes the string. The returned String starts and ends with the quoting char (') but marks every occurence of the quoting char inside the original string with the escape char (\).

Parameters:
str - the original String
Returns:
the quoted original String

quoteString

public static java.lang.String quoteString(java.lang.String str,
                                           char qchar,
                                           char escchar)
Quotes the string with the given quoting char. The returned 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).

Parameters:
str - the original String
qchar - the quoting character
escchar - the escape character
Returns:
the quoted original String

quoteString

public 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. The returned 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).

Parameters:
str - the original String
qchar - the quoting character
escchar - the escape character
start_end_with_qchar - if true, the string will start end end with the qchar
escape_escchar - if true, occurences of escchar in the source string will be escaped with that char too
Returns:
the quoted original String

removeChar

public static java.lang.String removeChar(java.lang.String str,
                                          char removeChar)
Removes the given char from the given string.

Parameters:
str - the String
removeChar - the character to remove from str
Returns:
the string without the given character

removeSpaces

public static java.lang.String removeSpaces(java.lang.String str)
Removes the given char from the given string.

Parameters:
str - the String
Returns:
the string without the given character

unquoteString

public static java.lang.String unquoteString(java.lang.String str)
Unquotes the string using a quoting char (') and escape char (\). This method does the opposide of quoteString(java.lang.String).

Parameters:
str - the quoted String
Returns:
the unquoted original String

unquoteString

public static java.lang.String unquoteString(java.lang.String str,
                                             char qchar,
                                             char escchar)
Unquotes the string using the given quoting char and escape char. This method does the opposide of quoteString(java.lang.String).

Parameters:
str - the quoted String
qchar - the quoting character
escchar - the escape character
Returns:
the unquoted original String

getClassName

public static java.lang.String getClassName(java.lang.Class cls)
Returns the class name only (without the package name) of the given Class.

Parameters:
cls - the Class to extract class name of
Returns:
the class name without the package name of the class.

getHTMLLabelString

public static java.lang.String getHTMLLabelString(java.lang.String label_text)
Returns a Swing-style html-text for the given label text with line breaks.

Parameters:
label_text - the label text
Returns:
the html-convertet text

wrapString

public 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

Parameters:
input_string - the input string
max_char_count - maximum characters per line (incl. space)
wrapStyleWord - true: whole words won't be wrapped false: wrapping can occur within a word
keepOriginalLineWraps - true: original wrapping will be kept (\n) false: original wrapping will be ignored
Returns:
a new string with inserted new lines (\n)

extractCVSRevision

public static java.lang.String extractCVSRevision(java.lang.String revision)
Extracts the cvs-revision out of the given string.

Parameters:
revision - the string containing a CVS-revision
Returns:
the extracted cvs-revision

extractFirstFewWords

public 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.

Parameters:
text - the text to extract words from (not null)
max_length - the maximum length of the excerpt line
use_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)
Returns:
the extracted words

cutString

public 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. It does it the following way:
  1. If the text is shorter than max_length, returns the text.
  2. If there is a word at the cutting position, cut it before the word, except the word reaches too long into the cut string, meaning the new cut position is in the first two thirds of the cutted string. The cutted_marker is appended at the end of the cutted string.
  3. If the last word is too long, the cut position is moved to 2/3 of the maximum length, the word is cut at the position, the cutted_marked is inserted there and the last few characters of the word are appended.


convertCamelCaseName

public 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.

Parameters:
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 parts
leading_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.
Returns:
the converted string

unquoteURLName

public static java.lang.String unquoteURLName(java.lang.String escaped_path)
Decodes url-encoded name, which has '%'-escaped characters and returns it as normal string.

Parameters:
escaped_path - the url-encoded name containing '%'-escaped characters
Returns:
the converted name.

hexCharToInt

public static int hexCharToInt(char hex_char)
Converts the given hexadecimal character into it's numeric value.

Parameters:
hex_char - the character to convert
Returns:
the numeric value

replace

public 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.

Parameters:
string - the string to replace occurences of the search string
search - the search string
replace - the replace string
Returns:
the replaced string

ident

public 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.

Parameters:
source - the source string
ident - the ident string
ident_first - if true, the first line will also be idented
Returns:
the idented string

readList

public 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.

Parameters:
string - the source string
seperators - the separating characters (if null uses default)
Returns:
the list of elements

getWordEndIndex

public 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.

Parameters:
string - the string to get the end index of the word of
seperators - the separators
forward - if true looks for the end of the word in forward direction, otherwise looks for it backward
Returns:
the end index of the word at the offset

getWordStartIndex

public 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.

Parameters:
string - the string to get the start index of the next word of
seperators - the separators
forward - if true looks for the start of the word in forward direction, otherwise looks for it backward
Returns:
the start index of the word after the offset

readNameValueParameters

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)
Decodes a string as name-value pairs, where values can be quoted.

Parameters:
string - the string to parse
param_eq - the character that separates key from values
param_seps - the character that separates key-value pairs
quote_char - the quoting character
quote_esc - the escape character for quoting character
params - the map of parameters to fill
Returns:
the default parameter (name is missing)

findOutsideQuotes

public 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

Parameters:
string - the string to look into
index - the starting index to search for
stop_chars - the stop characters looking for
quote_char - the quoting character
quote_esc - the escape character for quoting character
Returns:
the index in the given string, where a stop character was found first or -1 if no stop character was found

findOutsideBraces

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)
Finds any of the stop characters in the given string starting at a given index, which are not quoted

Parameters:
string - the string to look into
index - the starting index to search for
stop_chars - the stop characters looking for
brace_in_char - the character to open a brace
brace_out_char - the character to close a brace
quote_esc - the escape character for quoting character
Returns:
the index in the given string, where a stop character was found first or -1 if no stop character was found

replaceAll

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)
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.

Parameters:
string - the String to replace occurences of
quote_start - the start quoting string
quote_end - the end quoting string
variables - the varibles array with the names to replace
replacements - the replacement string array with the strings to replace the variable of the same index with
leave_quotes - if true, the result string still contains the source quotes around the replacement string
Returns:
the replaced string

findNextVariable

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)
Finds the next variable in the string. A variable has a name and optional parameters. This method returns the indices of the start point of the variable, the start of the parameter section and the start of the next character after the variable into the returned integer array. The variable name is put into the given String array.

Parameters:
string - the string to parse
start_index - the index to start from
variable_prefix - the prefix of the variable
variable_postfix - the postfix of the variable (may be null)
param_separators - the characters that separates the variable name from possible parameters
variable_name - array to store the variable name into at index 0 (must have at least size 1)
Returns:
an array with three elements; element 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.

mformat

public static java.lang.String mformat(java.lang.String pattern,
                                       java.util.Map arguments)
Formats the given pattern using the arguments given. The arguments are given as name-value mappings, where the names must be Strings. The pattern is formatted like the Java-default MessageFormat-patterns, but with clear-text-names instead of indexes.

Parameters:
pattern - the message pattern (not null)
arguments - the message arguments (if null, simply the pattern is returned)
Returns:
the formatted string
Throws:
java.lang.ClassCastException - if a name in the mapping is not a String
java.lang.IllegalArgumentException - if a name is null or empty

mformat

public static java.lang.String mformat(java.lang.String pattern,
                                       java.util.HashMap arguments)
Formats the given pattern using the arguments given. The arguments are given as name-value mappings, where the names must be Strings. The pattern is formatted like the Java-default MessageFormat-patterns, but with clear-text-names instead of indexes.

Parameters:
pattern - the message pattern (not null)
arguments - the message arguments (if null, simply the pattern is returned)
Returns:
the formatted string
Throws:
java.lang.ClassCastException - if a name in the mapping is not a String
java.lang.IllegalArgumentException - if a name is null or empty

mformat

public 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. The arguments are given as name-value mappings, where the names must be Strings

Parameters:
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
Returns:
the formatted string
Throws:
java.lang.IllegalArgumentException - if a name is null or empty

mformat

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)
Formats the given pattern using the arguments given. The arguments are given as name-value mappings, where the names must be Strings

Parameters:
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
name2 - the 2nd name variable to be replaced (not null)
argument2 - the 2nd argument variable for the corresponding name
Returns:
the formatted string
Throws:
java.lang.IllegalArgumentException - if a name is null or empty

mformat

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)
Formats the given pattern using the arguments given. The arguments are given as name-value mappings, where the names must be Strings

Parameters:
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
name2 - the 2nd name variable to be replaced (not null)
argument2 - the 2nd argument variable for the corresponding name
name3 - the 3rd name variable to be replaced (not null)
argument3 - the 3rd argument variable for the corresponding name
Returns:
the formatted string
Throws:
java.lang.IllegalArgumentException - if a name is null or empty

mformat

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)
Formats the given pattern using the arguments given. The arguments are given as name-value mappings, where the names must be Strings

Parameters:
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
name2 - the 2nd name variable to be replaced (not null)
argument2 - the 2nd argument variable for the corresponding name
name3 - the 3rd name variable to be replaced (not null)
argument3 - the 3rd argument variable for the corresponding name
name4 - the 4th name variable to be replaced (not null)
argument4 - the 4th argument variable for the corresponding name
Returns:
the formatted string
Throws:
java.lang.IllegalArgumentException - if a name is null or empty

mformat

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)
Formats the given pattern using the arguments given. The arguments are given as name-value mappings, where the names must be Strings

Parameters:
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
name2 - the 2nd name variable to be replaced (not null)
argument2 - the 2nd argument variable for the corresponding name
name3 - the 3rd name variable to be replaced (not null)
argument3 - the 3rd argument variable for the corresponding name
name4 - the 4th name variable to be replaced (not null)
argument4 - the 4th argument variable for the corresponding name
name5 - the 5th name variable to be replaced (not null)
argument5 - the 5th argument variable for the corresponding name
Returns:
the formatted string
Throws:
java.lang.IllegalArgumentException - if a name is null or empty

format

public static java.lang.String format(java.lang.String pattern,
                                      java.lang.Object[] arguments)
Formats the given pattern using the arguments given.

Parameters:
pattern - the message pattern
arguments - the message arguments (if null, simply the pattern is returned)

format

public static java.lang.String format(java.lang.String pattern,
                                      java.lang.Object argument1)
Formats the given pattern using the arguments given.


format

public 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.


format

public 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.


format

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)
Formats the given pattern using the arguments given.