Class TextUtils
java.lang.Object
org.apache.hc.core5.util.TextUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final char[]Returns a hexadecimal string with lowercase letters, representing the values of thebytes. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic bytecastAsByte(int c) Casts character to byte filtering non-visible and non-ASCII characters before conversion.static booleanTests whether a CharSequence contains any whitespace.static booleanDetermines whether the givenCharSequencecontains only ASCII characters.static booleanChecks if a CharSequence is empty (""), null or whitespace only.static booleanTests whether the parameter is null or of zero length.static intlength(CharSequence cs) Gets a CharSequence length or0if the CharSequence isnull.static StringtoHexString(byte[] bytes) static StringConverts a String to its lower case representation usingLocale.ROOT.
-
Field Details
-
HEX_CHARS
private static final char[] HEX_CHARSReturns a hexadecimal string with lowercase letters, representing the values of thebytes.- Since:
- 5.0
-
-
Constructor Details
-
TextUtils
private TextUtils()
-
-
Method Details
-
isEmpty
Tests whether the parameter is null or of zero length.- Parameters:
s- The CharSequence to test.- Returns:
- whether the parameter is null or of zero length.
-
isBlank
Checks if a CharSequence is empty (""), null or whitespace only.
Whitespace is defined by
Character.isWhitespace(char).TextUtils.isBlank(null) = true TextUtils.isBlank("") = true TextUtils.isBlank(" ") = true TextUtils.isBlank("abg") = false TextUtils.isBlank(" abg ") = false- Parameters:
s- the CharSequence to check, may be null- Returns:
trueif the CharSequence is null, empty or whitespace only
-
length
Gets a CharSequence length or0if the CharSequence isnull.- Parameters:
cs- a CharSequence ornull- Returns:
- CharSequence length or
0if the CharSequence isnull. - Since:
- 5.1
-
containsBlanks
Tests whether a CharSequence contains any whitespace.- Parameters:
s- The CharSequence to test.- Returns:
- whether a CharSequence contains any whitespace.
- Since:
- 4.4
-
toHexString
-
toLowerCase
Converts a String to its lower case representation usingLocale.ROOT.- Parameters:
s- The String to convert- Returns:
- The converted String.
- Since:
- 5.2
-
isAllASCII
Determines whether the givenCharSequencecontains only ASCII characters.- Parameters:
s- theCharSequenceto check- Returns:
- true if the
CharSequencecontains only ASCII characters, false otherwise - Throws:
IllegalArgumentException- if the inputCharSequenceis null- Since:
- 5.3
-
castAsByte
Casts character to byte filtering non-visible and non-ASCII characters before conversion.- Parameters:
c- The character to cast.- Returns:
- The given character or
'?'. - Since:
- 5.2
-