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 booleanisNullOrEmpty(String string) Returnstrueif the given string is null or is the empty string.private static booleanisPrintableChar(char ch) static booleanisPrintableString(String str) Determines whether theStringcontains only printable characters.static StringPads a given string on the left with leading 0's up the length.private static StringReturns a string, of length at leastminLength, consisting ofstringprepended with as many copies ofpadCharas are necessary to reach that length.
-
Constructor Details
-
StringUtils
private StringUtils()
-
-
Method Details
-
isNullOrEmpty
Returnstrueif 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:
trueif 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 ofstringprepended with as many copies ofpadCharas are necessary to reach that length. For example,padStart("7", 3, '0')returns"007"padStart("2010", 3, '0')returns"2010"
See
Formatterfor 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 theStringcontains only printable characters.- Parameters:
str- theStringto be validated.- Returns:
- whether the
Stringcontains only printable characters.
-
isPrintableChar
private static boolean isPrintableChar(char ch)
-