public final class JkUtilsString
extends java.lang.Object
Constructor and Description |
---|
JkUtilsString() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
capitalize(java.lang.String string)
Returns the specified string but upper-casing its first character.
|
static java.lang.String |
conformPackageName(java.lang.String string)
Converts the supplied String to a string suitable to be used as a package name.
|
static int |
countOccurence(java.lang.String matchedString,
char occurrence)
Returns occurrence count of the specified character into the specified
string.
|
static java.lang.String |
elipse(java.lang.String string,
int max)
Returns the specified string truncated and ending with ... if the specified
string is longer than the specified max length.
|
static boolean |
endsWithAny(java.lang.String stringToMatch,
java.lang.String... candidates)
Returns
true if the specified string ends with any of the
candidates. |
static boolean |
equals(java.lang.String string1,
java.lang.String string2)
Null safe equals
|
static boolean |
equalsAny(java.lang.String stringToMatch,
java.lang.String... candidates)
Returns
true if any of the candidate string is equal to the
string to match. |
static java.lang.String |
escapeHtml(java.lang.String s)
Returns the specified string replacing the HTML special characters by
their respective code.
|
static java.lang.String |
firstMatching(java.lang.String stringToMatch,
java.lang.String... candidates)
Returns the first string out of the specified candidates matching the
specified string.
|
static boolean |
isBlank(java.lang.String string)
Checks if a String is whitespace, empty ("") or null.
|
static java.lang.String |
join(java.lang.Iterable<?> items,
java.lang.String separator)
Same as
join(String[], String) but expecting an Iterable
instead of an array |
static java.lang.String |
join(java.lang.String[] items,
java.lang.String separator)
Creates a string by concatenating items array of specified items,
separating each with the specified separator.
|
static <T> T |
parse(java.lang.Class<T> type,
java.lang.String stringValue)
Create an instance of the specified type from its string value.
|
static java.lang.String |
plurialize(int count,
java.lang.String singular)
Returns a string containing the quantity and noun.
|
static java.lang.String |
plurialize(int count,
java.lang.String singular,
java.lang.String plurial)
Returns a string containing the quantity and noun.
|
static java.lang.String |
repeat(java.lang.String pattern,
int count)
Returns a string made of the the specified pattern repeat the
specified count.
|
static java.lang.String[] |
splitTrimed(java.lang.String str,
java.lang.String delimiters)
Splits the specified String into an array by separating by the specified
delimiter.
|
static boolean |
startsWithAny(java.lang.String stringToMatch,
java.lang.String... stringToCheckEquals)
Returns
true if the specified string starts with any of the
candidates. |
static java.lang.String |
substringAfterFirst(java.lang.String string,
java.lang.String delimiter)
Returns the substring after the first delimiter of the specified
occurrence.
|
static java.lang.String |
substringAfterLast(java.lang.String string,
java.lang.String delimiter)
Returns the substring after the last delimiter of the specified
occurrence.
|
static java.lang.String |
substringBeforeFirst(java.lang.String string,
java.lang.String delimiter)
Returns the substring before the first delimiter of the specified
occurrence.
|
static java.lang.String |
substringBeforeLast(java.lang.String string,
java.lang.String delimiter)
Returns the substring before the last delimiter of the specified
occurrence.
|
static java.lang.String |
toHexString(byte[] raw)
Returns the hexadecimal for of the given array of bytes.
|
static java.lang.String[] |
translateCommandline(java.lang.String toProcess)
Kindly borrowed from ANT
|
static java.lang.String |
uncapitalize(java.lang.String string)
Returns the specified string but lower-casing its first character.
|
public static java.lang.String join(java.lang.String[] items, java.lang.String separator)
public static java.lang.String join(java.lang.Iterable<?> items, java.lang.String separator)
join(String[], String)
but expecting an Iterable
instead of an arraypublic static java.lang.String capitalize(java.lang.String string)
public static java.lang.String uncapitalize(java.lang.String string)
public static java.lang.String firstMatching(java.lang.String stringToMatch, java.lang.String... candidates)
public static int countOccurence(java.lang.String matchedString, char occurrence)
public static java.lang.String[] splitTrimed(java.lang.String str, java.lang.String delimiters)
str
is null
then it returns an
empty array.public static java.lang.String substringAfterLast(java.lang.String string, java.lang.String delimiter)
public static java.lang.String substringBeforeFirst(java.lang.String string, java.lang.String delimiter)
public static java.lang.String substringAfterFirst(java.lang.String string, java.lang.String delimiter)
public static java.lang.String substringBeforeLast(java.lang.String string, java.lang.String delimiter)
public static java.lang.String repeat(java.lang.String pattern, int count)
repeat("##", 3)
will return ######public static java.lang.String plurialize(int count, java.lang.String singular, java.lang.String plurial)
public static java.lang.String plurialize(int count, java.lang.String singular)
public static <T> T parse(java.lang.Class<T> type, java.lang.String stringValue) throws java.lang.IllegalArgumentException
File
java.lang.IllegalArgumentException
public static java.lang.String toHexString(byte[] raw) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public static boolean equalsAny(java.lang.String stringToMatch, java.lang.String... candidates)
true
if any of the candidate string is equal to the
string to match.public static boolean equals(java.lang.String string1, java.lang.String string2)
public static boolean endsWithAny(java.lang.String stringToMatch, java.lang.String... candidates)
true
if the specified string ends with any of the
candidates.public static boolean startsWithAny(java.lang.String stringToMatch, java.lang.String... stringToCheckEquals)
true
if the specified string starts with any of the
candidates.public static boolean isBlank(java.lang.String string)
public static java.lang.String escapeHtml(java.lang.String s)
public static java.lang.String elipse(java.lang.String string, int max)
public static java.lang.String[] translateCommandline(java.lang.String toProcess)
public static java.lang.String conformPackageName(java.lang.String string)