public final class StringUtils extends Object
Modifier and Type | Method and Description |
---|---|
static String |
capitalize(String str)
Borrowed from commons-lang
StringUtils.capitalize() method. |
static int |
compareIgnoreCase(String a,
String b)
Compare two strings, ignoring case.
|
static int |
compareWithCase(String a,
String b)
Compare two strings, honoring case.
|
static boolean |
equalsIgnoreCase(String a,
String b)
Test if two strings are equal, ignoring case.
|
static boolean |
isEmptyOrNull(String stringValue)
Test if a string is empty or null.
|
static String |
join(Collection<String> parts,
String separator)
Join a collection of Strings together using the specified separator.
|
static String |
join(Collection<String> parts,
String separator,
String lastSeparator)
Join a collection of Strings together using the specified separator and a
lastSeparator which is used for joining the second last and the last
part.
|
static String |
replaceLineBreaksWithSpace(String in)
Replace CRLF, CR or LF with a single space.
|
static boolean |
toBoolean(String stringValue)
Parse a string as a standard Git boolean value.
|
static Boolean |
toBooleanOrNull(String stringValue)
Parse a string as a standard Git boolean value.
|
static char |
toLowerCase(char c)
Convert the input to lowercase.
|
static String |
toLowerCase(String in)
Convert the input string to lower case, according to the "C" locale.
|
public static char toLowerCase(char c)
This method does not honor the JVM locale, but instead always behaves as though it is in the US-ASCII locale. Only characters in the range 'A' through 'Z' are converted. All other characters are left as-is, even if they otherwise would have a lowercase character equivalent.
c
- the input character.public static String toLowerCase(String in)
This method does not honor the JVM locale, but instead always behaves as though it is in the US-ASCII locale. Only characters in the range 'A' through 'Z' are converted, all other characters are left as-is, even if they otherwise would have a lowercase character equivalent.
in
- the input string. Must not be null.public static String capitalize(String str)
StringUtils.capitalize()
method.
Capitalizes a String changing the first letter to title case as per
Character.toTitleCase(char)
. No other letters are changed.
null
input String returns null
.str
- the String to capitalize, may be nullnull
if null String inputpublic static boolean equalsIgnoreCase(String a, String b)
This method does not honor the JVM locale, but instead always behaves as though it is in the US-ASCII locale.
a
- first string to compare.b
- second string to compare.public static int compareIgnoreCase(String a, String b)
This method does not honor the JVM locale, but instead always behaves as though it is in the US-ASCII locale.
a
- first string to compare.b
- second string to compare.public static int compareWithCase(String a, String b)
This method does not honor the JVM locale, but instead always behaves as though it is in the US-ASCII locale.
a
- first string to compare.b
- second string to compare.public static boolean toBoolean(String stringValue)
toBooleanOrNull(String)
.stringValue
- the string to parse.value
.IllegalArgumentException
- if value
is not recognized as one of the standard
boolean names.public static Boolean toBooleanOrNull(String stringValue)
The terms yes
, true
, 1
, on
can all be
used to mean true
.
The terms no
, false
, 0
, off
can all be
used to mean false
.
Comparisons ignore case, via equalsIgnoreCase(String, String)
.
stringValue
- the string to parse.value
or null in case the
string does not represent a boolean valuepublic static String join(Collection<String> parts, String separator)
parts
- Strings to joinseparator
- used to joinpublic static String join(Collection<String> parts, String separator, String lastSeparator)
parts
- Strings to joinseparator
- separator used to join all but the two last elementslastSeparator
- separator to use for joining the last two elementspublic static boolean isEmptyOrNull(String stringValue)
stringValue
- the string to checktrue
if the string is null
or emptyCopyright © 2017 Eclipse JGit Project. All rights reserved.