| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.jgoodies.common.base.Strings
public class Strings
Provides frequently used static null-safe String testing methods .
| Constructor Summary | |
|---|---|
| protected  | Strings() | 
| Method Summary | |
|---|---|
| static String | abbreviateCenter(String str,
                 int maxLength)Abbreviates the given string if it exceeds the given maximum length by replacing its center part with an ellipsis ('…'). | 
| static boolean | isBlank(String str)Checks if the given string is whitespace, empty ("") or null. | 
| static boolean | isEmpty(String str)Checks if the given string is empty ("") or null. | 
| static boolean | isNotBlank(String str)Checks if the given string is not empty (""), not nulland not whitespace only. | 
| static boolean | isNotEmpty(String str)Checks if the given string is not empty ("") and not null. | 
| static boolean | isTrimmed(String str)Checks if the given string is null, empty (""),
 or the first and last characters are not whitespace. | 
| static boolean | startsWithIgnoreCase(String str,
                     String prefix)Checks if strstarts with the given prefix ignoring cases. | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Constructor Detail | 
|---|
protected Strings()
| Method Detail | 
|---|
public static boolean isBlank(String str)
null.
 
 Strings.isBlank(null)    == true
 Strings.isBlank("")      == true
 Strings.isBlank(" ")     == true
 Strings.isBlank(" abc")  == false
 Strings.isBlank("abc ")  == false
 Strings.isBlank(" abc ") == false
 
str - the string to check, may be null
true if the string is whitespace, empty
    or nullisEmpty(String)public static boolean isNotBlank(String str)
null and not whitespace only.
 
 Strings.isNotBlank(null)    == false
 Strings.isNotBlank("")      == false
 Strings.isNotBlank(" ")     == false
 Strings.isNotBlank(" abc")  == true
 Strings.isNotBlank("abc ")  == true
 Strings.isNotBlank(" abc ") == true
 
str - the string to check, may be null
true if the string is not empty
    and not null and not whitespace onlyisEmpty(String)public static boolean isEmpty(String str)
null.
 
 Strings.isEmpty(null)  == true
 Strings.isEmpty("")    == true
 Strings.isEmpty(" ")   == false
 Strings.isEmpty("Hi ") == false
 
str - the string to check, may be null
true if the string is empty or nullisBlank(String)public static boolean isNotEmpty(String str)
null.
 
 Strings.isNotEmpty(null)  == false
 Strings.isNotEmpty("")    == false
 Strings.isNotEmpty(" ")   == true
 Strings.isNotEmpty("Hi")  == true
 Strings.isNotEmpty("Hi ") == true
 
str - the string to check, may be null
true if the string is not empty and not nullisBlank(String)public static boolean isTrimmed(String str)
null, empty (""),
 or the first and last characters are not whitespace.
 
 Strings.isTrimmed(null)  == true
 Strings.isTrimmed("")    == true
 Strings.isTrimmed(" ")   == false
 Strings.isTrimmed("Hi")  == true
 Strings.isTrimmed("Hi ") == false
 Strings.isTrimmed(" Hi") == false
 
str - the string to check, may be null
true if the string is null, empty,
    or the first and last characters are not whitespace.
public static boolean startsWithIgnoreCase(String str,
                                           String prefix)
str starts with the given prefix ignoring cases.
 null is handled safely; if both arguments are null, true
 is returned, false otherwise.
 
 Strings.startsWithIgnoreCase(null, null)      == true
 Strings.startsWithIgnoreCase("a", null)       == false
 Strings.startsWithIgnoreCase(null, "a")       == false
 Strings.startsWithIgnoreCase("",  "")         == true
 Strings.startsWithIgnoreCase(" ", "")         == true
 Strings.startsWithIgnoreCase("John", "J")     == true
 Strings.startsWithIgnoreCase("John", "Jo")    == true
 Strings.startsWithIgnoreCase("John", "Joh")   == true
 Strings.startsWithIgnoreCase("John", "joh")   == true
 Strings.startsWithIgnoreCase("john", "Joh")   == true
 Strings.startsWithIgnoreCase("john", "joh")   == true
 Strings.startsWithIgnoreCase("John", "John")  == true
 Strings.startsWithIgnoreCase("John", "john")  == true
 Strings.startsWithIgnoreCase("John", "Jonny") == false
 
str - the test string to check, may be nullprefix - the prefix to check for, may be null
true, if the string starts with the prefix, ignoring cases,
     false otherwiseString.startsWith(java.lang.String)
public static String abbreviateCenter(String str,
                                      int maxLength)
null or shorter than the limit,
 it is returned as is.
 Strings.abbreviateCenter(null,      3) == null
 Strings.abbreviateCenter("",        3) == ""
 Strings.abbreviateCenter(" ",       3) == " "
 Strings.abbreviateCenter("a",       3) == "a"
 Strings.abbreviateCenter("ab",      3) == "ab"
 Strings.abbreviateCenter("abc",     3) == "abc"
 Strings.abbreviateCenter("abcd",    3) == "a…d"
 Strings.abbreviateCenter("abcde",   3) == "a…e"
 Strings.abbreviateCenter("abcde",   4) == "ab…e"
 Strings.abbreviateCenter("abcdef",  4) == "ab…f"
 Strings.abbreviateCenter("abcdefg", 5) == "ab…fg"
 
str - the source stringmaxLength - the maximum length of the result string
str if its length is less than or equal to maxLength,
     an abbreviated string with length maxLength where
     the center is replaced by an ellipsis| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||