Package io.opentelemetry.api.internal
Class StringUtils
java.lang.Object
io.opentelemetry.api.internal.StringUtils
Utilities for working with strings.
This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isNullOrEmpty
(String string) Returnstrue
if the given string is null or is the empty string.private static boolean
isPrintableChar
(char ch) static boolean
isPrintableString
(String str) Determines whether theString
contains only printable characters.static String
Pads a given string on the left with leading 0's up the length.private static String
Returns a string, of length at leastminLength
, consisting ofstring
prepended with as many copies ofpadChar
as are necessary to reach that length.
-
Constructor Details
-
StringUtils
private StringUtils()
-
-
Method Details
-
isNullOrEmpty
Returnstrue
if the given string is null or is the empty string.This method was copied verbatim from Guava library method com.google.common.base.Strings#isNullOrEmpty(java.lang.String).
- Parameters:
string
- a string reference to check- Returns:
true
if the string is null or is the empty string
-
padLeft
Pads a given string on the left with leading 0's up the length.- Parameters:
value
- the string to padminLength
- the minimum length the resulting padded string must have. Can be zero or negative, in which case the input string is always returned.- Returns:
- the padded string
-
padStart
Returns a string, of length at leastminLength
, consisting ofstring
prepended with as many copies ofpadChar
as are necessary to reach that length. For example,padStart("7", 3, '0')
returns"007"
padStart("2010", 3, '0')
returns"2010"
See
Formatter
for a richer set of formatting capabilities.This method was copied almost verbatim from Guava library method com.google.common.base.Strings#padStart(java.lang.String, int, char).
- Parameters:
string
- the string which should appear at the end of the resultminLength
- the minimum length the resulting string must have. Can be zero or negative, in which case the input string is always returned.padChar
- the character to insert at the beginning of the result until the minimum length is reached- Returns:
- the padded string
-
isPrintableString
Determines whether theString
contains only printable characters.- Parameters:
str
- theString
to be validated.- Returns:
- whether the
String
contains only printable characters.
-
isPrintableChar
private static boolean isPrintableChar(char ch)
-