Modifier and Type | Method and Description |
---|---|
static boolean |
isBlank(CharSequence cs)
Checks if a CharSequence is empty (""), null or whitespace only.
|
static boolean |
isEmpty(CharSequence cs)
Checks if a CharSequence is empty ("") or null.
|
static int |
length(CharSequence cs)
Gets a CharSequence length or
0 if the CharSequence is
null . |
static String |
trim(String str)
Removes control characters (char <= 32) from both
ends of this String, handling
null by returning
null . |
static String |
trimToEmpty(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 . |
static String |
trimToNull(String str)
Removes control characters (char <= 32) from both
ends of this String returning
null if the String is
empty ("") after the trim or if it is null . |
public static String trim(String str)
Removes control characters (char <= 32) from both
ends of this String, handling null
by returning
null
.
The String is trimmed using String.trim()
.
Trim removes start and end characters <= 32.
StringUtils.trim(null) = null StringUtils.trim("") = "" StringUtils.trim(" ") = "" StringUtils.trim("abc") = "abc" StringUtils.trim(" abc ") = "abc"
str
- the String to be trimmed, may be nullnull
if null String inputpublic static String trimToEmpty(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"
str
- the String to be trimmed, may be nullnull
inputpublic static String trimToNull(String str)
Removes control characters (char <= 32) from both
ends of this String returning null
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.trimToNull(null) = null StringUtils.trimToNull("") = null StringUtils.trimToNull(" ") = null StringUtils.trimToNull("abc") = "abc" StringUtils.trimToNull(" abc ") = "abc"
str
- the String to be trimmed, may be nullnull
if only chars <= 32, empty
or null String inputpublic static boolean isEmpty(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
cs
- the CharSequence to check, may be nulltrue
if the CharSequence is empty or nullpublic static boolean isBlank(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
cs
- the CharSequence to check, may be nulltrue
if the CharSequence is null, empty or whitespace onlypublic static int length(CharSequence cs)
0
if the CharSequence is
null
.cs
- a CharSequence or null
0
if the CharSequence is
null
.Copyright © 2013–2022. All rights reserved.