|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.jdroid.java.utils.StringUtils
public abstract class StringUtils
This class contains functions for managing Strings
| Field Summary | |
|---|---|
static String |
BANG
|
static String |
COMMA
|
static String |
DASH
|
static String |
DOT
|
static String |
ELLIPSIS
|
static String |
EMPTY
|
static String |
NEW_LINE
|
static String |
PIPE
|
static String |
SLASH
|
static String |
SPACE
|
static String |
UNDERSCORE
|
| Constructor Summary | |
|---|---|
StringUtils()
|
|
| Method Summary | |
|---|---|
static String |
capitalize(String text)
|
static String |
capitalizeWords(String str)
Capitalizes all the whitespace separated words in a String. |
static String |
capitalizeWords(String str,
char[] delimiters)
Capitalizes all the delimiter separated words in a String. |
static String |
defaultString(String str)
Returns either the passed in String, or if the String is null, an empty String (""). |
static String |
defaultString(String str,
String defaultString)
|
static Boolean |
equal(String text1,
String text2)
|
static Set<String> |
extractPlaceHolders(String string)
Extract all the placeholder's names of the string |
static String |
getFirstToken(String string)
Returns the first token of the string if that string can be split by a ",", else return the unmodified input string |
static String |
getFirstToken(String string,
String token)
Returns the first token of the string if that string can be split by the token, else return the unmodified input string |
static String |
getNotEmptyString(String text)
|
static boolean |
hasOnlyCharacters(String name)
|
static boolean |
isBlank(String str)
Checks if a String is whitespace, empty ("") or null. |
static Boolean |
isEmpty(String text)
|
static boolean |
isNotBlank(String str)
Checks if a String is not empty (""), not null and not whitespace only. |
static Boolean |
isNotEmpty(String text)
|
static String |
join(Collection<?> objectsToJoin)
Joins all the strings in the list in a single one separated by ','. |
static String |
join(Collection<?> objectsToJoin,
String separator)
Joins all the strings in the list in a single one separated by the separator sequence. |
static String |
replaceValues(String template,
Map<String,String> values)
|
static Collection<String> |
splitToCollection(String text)
|
static Collection<String> |
splitToCollection(String text,
String separator)
|
static String |
toAlphanumeric(String value)
Transform the received value removing all the not alphanumeric or spaces characters |
static String |
truncate(String text,
Integer maxCharacters)
Truncate the text adding "...". |
static String |
truncate(String text,
Integer maxCharacters,
Boolean truncateWords)
Truncate the text adding "..." if the truncateWords parameter is true. |
static String |
wordWrapToTwoLines(String text,
int minLength)
This method word wrap a text to two lines if the text has multiple words and its length is greater than the specified minLength. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String EMPTY
public static final String ELLIPSIS
public static final String COMMA
public static final String SPACE
public static final String DASH
public static final String SLASH
public static final String DOT
public static final String NEW_LINE
public static final String UNDERSCORE
public static final String BANG
public static final String PIPE
| Constructor Detail |
|---|
public StringUtils()
| Method Detail |
|---|
public static String getNotEmptyString(String text)
public static Boolean equal(String text1,
String text2)
public static Boolean isEmpty(String text)
public static Boolean isNotEmpty(String text)
public static boolean isBlank(String str)
Checks if a String is whitespace, empty ("") or null.
StringUtils.isBlank(null) = true
StringUtils.isBlank("") = true
StringUtils.isBlank(" ") = true
StringUtils.isBlank("bob") = false
StringUtils.isBlank(" bob ") = false
str - the String to check, may be null
true if the String is null, empty or whitespacepublic static boolean isNotBlank(String str)
Checks if a String is not empty (""), not null and not whitespace only.
StringUtils.isNotBlank(null) = false
StringUtils.isNotBlank("") = false
StringUtils.isNotBlank(" ") = false
StringUtils.isNotBlank("bob") = true
StringUtils.isNotBlank(" bob ") = true
str - the String to check, may be null
true if the String is not empty and not null and not whitespacepublic static String defaultString(String str)
Returns either the passed in String, or if the String is null, an empty String ("").
StringUtils.defaultString(null) = ""
StringUtils.defaultString("") = ""
StringUtils.defaultString("bat") = "bat"
str - the String to check, may be null
null
public static String defaultString(String str,
String defaultString)
public static String capitalize(String text)
public static String capitalizeWords(String str)
Capitalizes all the whitespace separated words in a String. Only the first letter of each word is changed. To
convert the rest of each word to lowercase at the same time, use capitalize(String).
Whitespace is defined by Character.isWhitespace(char). A null input String returns
null. Capitalization uses the unicode title case, normally equivalent to upper case.
WordUtils.capitalize(null) = null
WordUtils.capitalize("") = ""
WordUtils.capitalize("i am FINE") = "I Am FINE"
str - the String to capitalize, may be null
null if null String input
public static String capitalizeWords(String str,
char[] delimiters)
Capitalizes all the delimiter separated words in a String. Only the first letter of each word is changed.
The delimiters represent a set of characters understood to separate words. The first string character and the first non-delimiter character after a delimiter will be capitalized.
A null input String returns null. Capitalization uses the unicode title case, normally
equivalent to upper case.
WordUtils.capitalize(null, *) = null
WordUtils.capitalize("", *) = ""
WordUtils.capitalize(*, new char[0]) = *
WordUtils.capitalize("i am fine", null) = "I Am Fine"
WordUtils.capitalize("i aM.fine", {'.'}) = "I aM.Fine"
str - the String to capitalize, may be nulldelimiters - set of characters to determine capitalization, null means whitespace
null if null String input
public static String join(Collection<?> objectsToJoin,
String separator)
objectsToJoin - The objects to join.separator - The separator sequence.
public static String join(Collection<?> objectsToJoin)
objectsToJoin - The objects to join.
public static String truncate(String text,
Integer maxCharacters,
Boolean truncateWords)
text - The text to truncatemaxCharacters - The maximum amount of characters allowed for the returned texttruncateWords - True if the words should be truncated
public static String truncate(String text,
Integer maxCharacters)
text - The text to truncatemaxCharacters - The maximum amount of characters allowed for the returned text
public static Set<String> extractPlaceHolders(String string)
string - The whole string with placeholders
public static String toAlphanumeric(String value)
value - The string to transform
public static Collection<String> splitToCollection(String text)
public static Collection<String> splitToCollection(String text,
String separator)
public static String getFirstToken(String string,
String token)
string - The string to splittoken - The token to use as splitter
public static String getFirstToken(String string)
string - The string to split
public static String wordWrapToTwoLines(String text,
int minLength)
text - A Sting, the text to word wrap to two lines.minLength - The min text length to appy word wrap.
public static String replaceValues(String template,
Map<String,String> values)
public static boolean hasOnlyCharacters(String name)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||