public class StringUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
COMMA_SEPARATOR |
static Charset |
UTF8 |
Constructor and Description |
---|
StringUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
appendCompactedString(StringBuilder destination,
String source)
This method appends a string to a string builder and collapses contiguous
white space is a single space.
|
static boolean |
beginsWithIgnoreCase(String data,
String seq)
Performs a case insensitive comparison and returns true if the data
begins with the given sequence.
|
static int |
compare(String str1,
String str2)
Compare two strings with Locale.ENGLISH
This method is preferred over String.compareTo() method.
|
static Character |
findFirstOccurrence(String s,
char... charsToMatch)
Searches a string for the first occurrence of a character specified by a list of characters.
|
static String |
fromBigDecimal(BigDecimal value) |
static String |
fromBigInteger(BigInteger value) |
static String |
fromBoolean(Boolean value) |
static String |
fromByte(Byte b)
Returns the string representation of the specified Byte.
|
static String |
fromByteBuffer(ByteBuffer byteBuffer)
Base64 encodes the data in the specified byte buffer (from the current
position to the buffer's limit) and returns it as a base64 encoded
string.
|
static String |
fromDate(Date value)
Converts the specified date to an ISO 8601 timestamp string and returns
it.
|
static String |
fromDate(Date date,
String timestampFormat) |
static String |
fromDouble(Double d)
Returns the string representation of the specified double.
|
static String |
fromFloat(Float value) |
static String |
fromInteger(Integer value) |
static String |
fromLong(Long value) |
static String |
fromShort(Short value) |
static String |
fromString(String value) |
static boolean |
hasValue(String str) |
static boolean |
isNullOrEmpty(String value) |
static String |
join(String joiner,
String... parts)
Joins the strings in parts with joiner between each string
|
static String |
lowerCase(String str)
Converts a given String to lower case with Locale.ENGLISH
|
static String |
replace(String originalString,
String partToMatch,
String replacement) |
static BigDecimal |
toBigDecimal(String s) |
static BigInteger |
toBigInteger(String s) |
static Boolean |
toBoolean(StringBuilder value) |
static Integer |
toInteger(StringBuilder value) |
static String |
toString(StringBuilder value) |
static String |
trim(String value)
A null-safe trim method.
|
static String |
upperCase(String str)
Converts a given String to upper case with Locale.ENGLISH
|
public static final String COMMA_SEPARATOR
public static final Charset UTF8
public static Integer toInteger(StringBuilder value)
public static String toString(StringBuilder value)
public static Boolean toBoolean(StringBuilder value)
public static String fromBigInteger(BigInteger value)
public static String fromBigDecimal(BigDecimal value)
public static BigInteger toBigInteger(String s)
public static BigDecimal toBigDecimal(String s)
public static String fromDate(Date value)
value
- The date to format as an ISO 8601 timestamp string.public static String fromDouble(Double d)
d
- The double to represent as a string.public static String fromByte(Byte b)
b
- The Byte to represent as a string.public static String fromByteBuffer(ByteBuffer byteBuffer)
byteBuffer
- The data to base64 encode and return as a string; must not be
null.public static String join(String joiner, String... parts)
joiner
- the string to insert between the strings in partsparts
- the parts to joinpublic static String trim(String value)
public static boolean isNullOrEmpty(String value)
public static boolean hasValue(String str)
public static String lowerCase(String str)
str
- the string to be converted to lower casepublic static String upperCase(String str)
str
- the string to be converted to upper casepublic static int compare(String str1, String str2)
str1
- String 1str2
- String 2IllegalArgumentException
- throws exception if both or either of the strings is nullpublic static void appendCompactedString(StringBuilder destination, String source)
public static boolean beginsWithIgnoreCase(String data, String seq)
public static Character findFirstOccurrence(String s, char... charsToMatch)
s
- The string to search.charsToMatch
- A list of characters to search the string for.