Class StringHelper
java.lang.Object
io.github.torand.javacommons.lang.StringHelper
Provides general purpose string utilities.
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
capitalize
(String string) Returns specified string with upper case first letter.static String
Creates a string by concatenating a substring multiple times.static String
Creates a string by concatenating a substring multiple times delimited by a delimiter substring.static boolean
Tests whether the specified string is null or contains no characters.static boolean
Tests whether the specified string is not null and contains at least one character.static String
Returns the specified string enclosed by double quotes.Returns specified list with all strings quoted.static Object
quoteIfString
(Object object) If the specified object is a string, returns it enclosed by double quotes.static String
Removes a specific number of leading characters from a string.static String
Removes a specific number of trailing characters from a string.static String
uncapitalize
(String string) Returns specified string with lower case first letter.
-
Method Details
-
nonBlank
Tests whether the specified string is not null and contains at least one character.- Parameters:
string
- the string to test.- Returns:
- true if the string is not null and contains at least one character; else false.
-
isBlank
Tests whether the specified string is null or contains no characters.- Parameters:
string
- the string to test.- Returns:
- true if the string is null or contains no characters; else false.
-
generate
Creates a string by concatenating a substring multiple times.- Parameters:
string
- the substring.count
- the number of repetitions.- Returns:
- the generated string.
-
generate
Creates a string by concatenating a substring multiple times delimited by a delimiter substring.- Parameters:
string
- the substring.count
- the number of repetitions.delimiter
- the delimiter.- Returns:
- the generated string.
-
quote
Returns the specified string enclosed by double quotes.- Parameters:
string
- the string.- Returns:
- the quoted string.
-
quoteIfString
If the specified object is a string, returns it enclosed by double quotes.- Parameters:
object
- the object, which might be a string.- Returns:
- the quoted string or unmodified object.
-
quoteAll
Returns specified list with all strings quoted.- Parameters:
strings
- the list.- Returns:
- the list of quoted strings.
-
stripHead
Removes a specific number of leading characters from a string.- Parameters:
string
- the string.count
- the number of characters to remove.- Returns:
- the stripped string.
-
stripTail
Removes a specific number of trailing characters from a string.- Parameters:
string
- the string.count
- the number of characters to remove.- Returns:
- the stripped string.
-
capitalize
Returns specified string with upper case first letter.- Parameters:
string
- the string.- Returns:
- the capitalized string.
-
uncapitalize
Returns specified string with lower case first letter.- Parameters:
string
- the string.- Returns:
- the uncapitalized string.
-