public class StringUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static char |
CHAR_CARRIAGE_RETURN |
private static char |
CHAR_FORM_FEED |
private static char |
CHAR_NEW_LINE |
private static char |
CHAR_SPACE |
private static char |
CHAR_TAB |
private static char |
CHAR_VERTICAL_TAB |
static java.lang.String |
COMMA_SEPARATOR |
private static java.lang.String |
DEFAULT_ENCODING |
private static java.util.Locale |
LOCALE_ENGLSIH |
static java.nio.charset.Charset |
UTF8 |
Constructor and Description |
---|
StringUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
appendCompactedString(java.lang.StringBuilder destination,
java.lang.String source)
This method appends a string to a string builder and collapses contiguous
white space is a single space.
|
static boolean |
beginsWithIgnoreCase(java.lang.String data,
java.lang.String seq)
Performs a case insensitive comparison and returns true if the data
begins with the given sequence.
|
static int |
compare(java.lang.String str1,
java.lang.String str2)
Compare two strings with Locale.ENGLISH
This method is preferred over String.compareTo() method.
|
static java.lang.String |
fromBigDecimal(java.math.BigDecimal value) |
static java.lang.String |
fromBigInteger(java.math.BigInteger value) |
static java.lang.String |
fromBoolean(java.lang.Boolean value) |
static java.lang.String |
fromByte(java.lang.Byte b)
Returns the string representation of the specified Byte.
|
static java.lang.String |
fromByteBuffer(java.nio.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 java.lang.String |
fromDate(java.util.Date value)
Converts the specified date to an ISO 8601 timestamp string and returns
it.
|
static java.lang.String |
fromDouble(java.lang.Double d)
Returns the string representation of the specified double.
|
static java.lang.String |
fromFloat(java.lang.Float value) |
static java.lang.String |
fromInteger(java.lang.Integer value) |
static java.lang.String |
fromLong(java.lang.Long value) |
static java.lang.String |
fromString(java.lang.String value) |
static boolean |
isNullOrEmpty(java.lang.String value) |
private static boolean |
isWhiteSpace(char ch)
Tests a char to see if is it whitespace.
|
static java.lang.String |
join(java.lang.String joiner,
java.lang.String... parts)
Joins the strings in parts with joiner between each string
|
static java.lang.String |
lowerCase(java.lang.String str)
Converts a given String to lower case with Locale.ENGLISH
|
static java.lang.String |
replace(java.lang.String originalString,
java.lang.String partToMatch,
java.lang.String replacement) |
static java.math.BigDecimal |
toBigDecimal(java.lang.String s) |
static java.math.BigInteger |
toBigInteger(java.lang.String s) |
static java.lang.Boolean |
toBoolean(java.lang.StringBuilder value) |
static java.lang.Integer |
toInteger(java.lang.StringBuilder value) |
static java.lang.String |
toString(java.lang.StringBuilder value) |
static java.lang.String |
trim(java.lang.String value)
A null-safe trim method.
|
static java.lang.String |
upperCase(java.lang.String str)
Converts a given String to upper case with Locale.ENGLISH
|
private static final java.lang.String DEFAULT_ENCODING
public static final java.lang.String COMMA_SEPARATOR
public static final java.nio.charset.Charset UTF8
private static final java.util.Locale LOCALE_ENGLSIH
private static final char CHAR_SPACE
private static final char CHAR_TAB
private static final char CHAR_NEW_LINE
private static final char CHAR_VERTICAL_TAB
private static final char CHAR_CARRIAGE_RETURN
private static final char CHAR_FORM_FEED
public static java.lang.Integer toInteger(java.lang.StringBuilder value)
public static java.lang.String toString(java.lang.StringBuilder value)
public static java.lang.Boolean toBoolean(java.lang.StringBuilder value)
public static java.lang.String fromInteger(java.lang.Integer value)
public static java.lang.String fromLong(java.lang.Long value)
public static java.lang.String fromString(java.lang.String value)
public static java.lang.String fromBoolean(java.lang.Boolean value)
public static java.lang.String fromBigInteger(java.math.BigInteger value)
public static java.lang.String fromBigDecimal(java.math.BigDecimal value)
public static java.math.BigInteger toBigInteger(java.lang.String s)
public static java.math.BigDecimal toBigDecimal(java.lang.String s)
public static java.lang.String fromFloat(java.lang.Float value)
public static java.lang.String fromDate(java.util.Date value)
value
- The date to format as an ISO 8601 timestamp string.public static java.lang.String fromDouble(java.lang.Double d)
d
- The double to represent as a string.public static java.lang.String fromByte(java.lang.Byte b)
b
- The Byte to represent as a string.public static java.lang.String fromByteBuffer(java.nio.ByteBuffer byteBuffer)
byteBuffer
- The data to base64 encode and return as a string; must not be
null.public static java.lang.String replace(java.lang.String originalString, java.lang.String partToMatch, java.lang.String replacement)
public static java.lang.String join(java.lang.String joiner, java.lang.String... parts)
joiner
- the string to insert between the strings in partsparts
- the parts to joinpublic static java.lang.String trim(java.lang.String value)
public static boolean isNullOrEmpty(java.lang.String value)
public static java.lang.String lowerCase(java.lang.String str)
str
- the string to be converted to lower casepublic static java.lang.String upperCase(java.lang.String str)
str
- the string to be converted to upper casepublic static int compare(java.lang.String str1, java.lang.String str2)
str1
- String 1str2
- String 2java.lang.IllegalArgumentException
- throws exception if both or either of the strings is nullprivate static boolean isWhiteSpace(char ch)
ch
- the character to be testedpublic static void appendCompactedString(java.lang.StringBuilder destination, java.lang.String source)
public static boolean beginsWithIgnoreCase(java.lang.String data, java.lang.String seq)