Package games.stendhal.server.util
Class StringUtils
java.lang.Object
games.stendhal.server.util.StringUtils
little methods to work with strings.
- Author:
- hendrik
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
countLowerCase(String text)
Counts the number of lower case characters.static int
countUpperCase(String text)
Counts the number of upper case characters.static String
generateStringOfCharacters(int count)
creates a random string which only consists of lettersstatic String
substitute(String string, Object... params)
Replaces [variables] in a stringstatic String
substitute(String string, Map<String,?> params)
Replaces [variables] in a stringstatic String
Converts a string to title case.static String
trims a string to the specified size.
-
Constructor Details
-
StringUtils
public StringUtils()
-
-
Method Details
-
countUpperCase
Counts the number of upper case characters.- Parameters:
text
- text to count- Returns:
- number of upper case characters
-
countLowerCase
Counts the number of lower case characters.- Parameters:
text
- text to count- Returns:
- number of lower case characters
-
generateStringOfCharacters
creates a random string which only consists of letters- Parameters:
count
- length of the string- Returns:
- generated string
-
substitute
Replaces [variables] in a string- Parameters:
string
- with [variables]params
- name1, value1, name2, value2, name3, value3- Returns:
- string with substituted parameters
-
substitute
Replaces [variables] in a string- Parameters:
string
- with [variables]params
- replacement parameters- Returns:
- string with substituted parameters
-
titleize
Converts a string to title case. Example: "hello world" is converted to "Hello World"- Parameters:
st
- String to be formatted.- Returns:
- Title case formatted string.
-
trimTo
trims a string to the specified size. It will not throw an error, if the string is already short enough.- Parameters:
string
- string to trim downsize
- size- Returns:
- trimmed string
-