Top Description Constructors Methods
io.opentelemetry.api.internal

public final Class StringUtils

extends Object
Class Inheritance
Annotations
@Immutable
Imports
java.util.Objects, javax.annotation.Nullable, javax.annotation.concurrent.Immutable

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

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static boolean

Returns:

true if the string is null or is the empty string
isNullOrEmpty
(String
a string reference to check
string
)

Returns true if the given string is null or is the empty string.

private static boolean
isPrintableChar(char ch)

public static boolean

Returns:

whether the String contains only printable characters.
isPrintableString
(String
the String to be validated.
str
)

Determines whether the String contains only printable characters.

public static String

Returns:

the padded string
padLeft
(String
the string to pad
value
,
int
the minimum length the resulting padded string must have. Can be zero or negative, in which case the input string is always returned.
minLength
)

Pads a given string on the left with leading 0's up the length.

private static String

Returns:

the padded string
padStart
(String
the string which should appear at the end of the result
string
,
int
the minimum length the resulting string must have. Can be zero or negative, in which case the input string is always returned.
minLength
,
char
the character to insert at the beginning of the result until the minimum length is reached
padChar
)

Returns a string, of length at least minLength, consisting of string prepended with as many copies of padChar as are necessary to reach that length.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

StringUtilsback to summary
private StringUtils()

Method Detail

isNullOrEmptyback to summary
public static boolean isNullOrEmpty(String string)

Returns true 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:String

a string reference to check

Returns:boolean

true if the string is null or is the empty string

Annotations
@Contract:null -> true
isPrintableCharback to summary
private static boolean isPrintableChar(char ch)
isPrintableStringback to summary
public static boolean isPrintableString(String str)

Determines whether the String contains only printable characters.

Parameters
str:String

the String to be validated.

Returns:boolean

whether the String contains only printable characters.

padLeftback to summary
public static String padLeft(String value, int minLength)

Pads a given string on the left with leading 0's up the length.

Parameters
value:String

the string to pad

minLength:int

the minimum length the resulting padded string must have. Can be zero or negative, in which case the input string is always returned.

Returns:String

the padded string

padStartback to summary
private static String padStart(String string, int minLength, char padChar)

Returns a string, of length at least minLength, consisting of string prepended with as many copies of padChar as are necessary to reach that length. For example,

  • padStart("7", 3, '0') returns "007"
  • padStart("2010", 3, '0') returns "2010"

See java.util.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:String

the string which should appear at the end of the result

minLength:int

the minimum length the resulting string must have. Can be zero or negative, in which case the input string is always returned.

padChar:char

the character to insert at the beginning of the result until the minimum length is reached

Returns:String

the padded string