Package com.github.tonyluo.excel.util
Class StringUtils
java.lang.Object
com.github.tonyluo.excel.util.StringUtils
public class StringUtils
extends java.lang.Object
copy from org.apache.commons.lang3.StringUtils
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
EMPTY
The empty String""
. -
Constructor Summary
Constructors Constructor Description StringUtils()
-
Method Summary
Modifier and Type Method Description static boolean
isBlank(java.lang.CharSequence cs)
Checks if a CharSequence is empty (""), null or whitespace only.static boolean
isEmpty(java.lang.CharSequence cs)
Checks if a CharSequence is empty ("") or null.static boolean
isNotBlank(java.lang.CharSequence cs)
Checks if a CharSequence is not empty (""), not null and not whitespace only.static boolean
isNotEmpty(java.lang.CharSequence cs)
Checks if a CharSequence is not empty ("") and not null.static java.lang.String
trimToEmpty(java.lang.String str)
Removes control characters (char <= 32) from both ends of this String returning an empty String ("") if the String is empty ("") after the trim or if it isnull
.
-
Field Details
-
EMPTY
public static final java.lang.String EMPTYThe empty String""
.- Since:
- 2.0
- See Also:
- Constant Field Values
-
-
Constructor Details
-
StringUtils
public StringUtils()
-
-
Method Details
-
isEmpty
public static boolean isEmpty(java.lang.CharSequence cs)Checks if a CharSequence is empty ("") or null.
StringUtils.isEmpty(null) = true StringUtils.isEmpty("") = true StringUtils.isEmpty(" ") = false StringUtils.isEmpty("bob") = false StringUtils.isEmpty(" bob ") = false
NOTE: This method changed in Lang version 2.0. It no longer trims the CharSequence. That functionality is available in isBlank().
- Parameters:
cs
- the CharSequence to check, may be null- Returns:
true
if the CharSequence is empty or null- Since:
- 3.0 Changed signature from isEmpty(String) to isEmpty(CharSequence)
-
isNotEmpty
public static boolean isNotEmpty(java.lang.CharSequence cs)Checks if a CharSequence is not empty ("") and not null.
StringUtils.isNotEmpty(null) = false StringUtils.isNotEmpty("") = false StringUtils.isNotEmpty(" ") = true StringUtils.isNotEmpty("bob") = true StringUtils.isNotEmpty(" bob ") = true
- Parameters:
cs
- the CharSequence to check, may be null- Returns:
true
if the CharSequence is not empty and not null- Since:
- 3.0 Changed signature from isNotEmpty(String) to isNotEmpty(CharSequence)
-
isBlank
public static boolean isBlank(java.lang.CharSequence cs)Checks if a CharSequence is empty (""), null or whitespace only.
Whitespace is defined by
Character.isWhitespace(char)
.StringUtils.isBlank(null) = true StringUtils.isBlank("") = true StringUtils.isBlank(" ") = true StringUtils.isBlank("bob") = false StringUtils.isBlank(" bob ") = false
- Parameters:
cs
- the CharSequence to check, may be null- Returns:
true
if the CharSequence is null, empty or whitespace only- Since:
- 2.0, 3.0 Changed signature from isBlank(String) to isBlank(CharSequence)
-
isNotBlank
public static boolean isNotBlank(java.lang.CharSequence cs)Checks if a CharSequence is not empty (""), not null and not whitespace only.
Whitespace is defined by
Character.isWhitespace(char)
.StringUtils.isNotBlank(null) = false StringUtils.isNotBlank("") = false StringUtils.isNotBlank(" ") = false StringUtils.isNotBlank("bob") = true StringUtils.isNotBlank(" bob ") = true
- Parameters:
cs
- the CharSequence to check, may be null- Returns:
true
if the CharSequence is not empty and not null and not whitespace only- Since:
- 2.0, 3.0 Changed signature from isNotBlank(String) to isNotBlank(CharSequence)
-
trimToEmpty
public static java.lang.String trimToEmpty(java.lang.String str)Removes control characters (char <= 32) from both ends of this String returning an empty String ("") if the String is empty ("") after the trim or if it is
null
.The String is trimmed using
String.trim()
. Trim removes start and end characters <= 32.StringUtils.trimToEmpty(null) = "" StringUtils.trimToEmpty("") = "" StringUtils.trimToEmpty(" ") = "" StringUtils.trimToEmpty("abc") = "abc" StringUtils.trimToEmpty(" abc ") = "abc"
- Parameters:
str
- the String to be trimmed, may be null- Returns:
- the trimmed String, or an empty String if
null
input - Since:
- 2.0
-