@API(status=INTERNAL, since="1.0") public final class StringUtils extends Object
Strings
,
CharSequences
, etc.
These utilities are intended solely for usage within the JUnit framework itself. Any usage by external parties is not supported. Use at your own risk!
Modifier and Type | Method and Description |
---|---|
static boolean |
containsIsoControlCharacter(String str)
Determine if the supplied
String contains any ISO control characters. |
static boolean |
containsWhitespace(String str)
Determine if the supplied
String contains any whitespace characters. |
static String |
defaultToString(Object obj)
Convert the supplied
Object to a default String
representation using the following algorithm. |
static boolean |
doesNotContainIsoControlCharacter(String str)
Determine if the supplied
String does not contain any ISO control
characters. |
static boolean |
doesNotContainWhitespace(String str)
Determine if the supplied
String does not contain any whitespace
characters. |
static boolean |
isBlank(String str)
Determine if the supplied
String is blank (i.e.,
null or consisting only of whitespace characters). |
static boolean |
isNotBlank(String str)
|
static String |
nullSafeToString(Object obj)
Convert the supplied
Object to a String using the
following algorithm. |
static String |
replaceIsoControlCharacters(String str,
String replacement)
Replace all ISO control characters in the supplied
String . |
static String |
replaceWhitespaceCharacters(String str,
String replacement)
Replace all whitespace characters in the supplied
String . |
public static boolean isBlank(String str)
String
is blank (i.e.,
null
or consisting only of whitespace characters).str
- the string to check; may be null
true
if the string is blankisNotBlank(String)
public static boolean isNotBlank(String str)
str
- the string to check; may be null
true
if the string is not blankisBlank(String)
public static boolean containsWhitespace(String str)
String
contains any whitespace characters.str
- the string to check; may be null
true
if the string contains whitespacecontainsIsoControlCharacter(String)
,
Character.isWhitespace(int)
public static boolean doesNotContainWhitespace(String str)
String
does not contain any whitespace
characters.str
- the string to check; may be null
true
if the string does not contain whitespacecontainsWhitespace(String)
,
containsIsoControlCharacter(String)
,
Character.isWhitespace(int)
public static boolean containsIsoControlCharacter(String str)
String
contains any ISO control characters.str
- the string to check; may be null
true
if the string contains an ISO control charactercontainsWhitespace(String)
,
Character.isISOControl(int)
public static boolean doesNotContainIsoControlCharacter(String str)
String
does not contain any ISO control
characters.str
- the string to check; may be null
true
if the string does not contain an ISO control charactercontainsIsoControlCharacter(String)
,
containsWhitespace(String)
,
Character.isISOControl(int)
public static String nullSafeToString(Object obj)
Object
to a String
using the
following algorithm.
null
, this method returns "null"
.Arrays#toString(...)
variant will be used to convert it to a String.Arrays#deepToString(Object[])
will be used to convert it to a String.toString()
on the object
will be returned.defaultToString(Object)
obj
- the object to convert to a String; may be null
null
Arrays.deepToString(Object[])
,
ClassUtils.nullSafeToString(Class...)
public static String defaultToString(Object obj)
Object
to a default String
representation using the following algorithm.
null
, this method returns "null"
.Object.toString()
by using the supplied
object's class name and hash code as follows:
obj.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(obj))
obj
- the object to convert to a String; may be null
null
nullSafeToString(Object)
,
ClassUtils.nullSafeToString(Class...)
@API(status=INTERNAL, since="1.4") public static String replaceIsoControlCharacters(String str, String replacement)
String
.str
- the string in which to perform the replacement; may be null
replacement
- the replacement string; never null
null
if the supplied string was null
@API(status=INTERNAL, since="1.4") public static String replaceWhitespaceCharacters(String str, String replacement)
String
.str
- the string in which to perform the replacement; may be null
replacement
- the replacement string; never null
null
if the supplied string was null
Copyright © 2021. All rights reserved.