Class EncodingUtils
- java.lang.Object
-
- org.springframework.cloud.sleuth.internal.EncodingUtils
-
public final class EncodingUtils extends Object
Adopted from OpenTelemetry API.- Since:
- 3.1.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte
byteFromBase16String(CharSequence chars, int offset)
Decodes the specified two character sequence, and returns the resultingbyte
.static void
byteToBase16(byte value, char[] dest, int destOffset)
static String
fromLong(long id)
Converts long into string.static String
fromLongs(long idHigh, long idLow)
Converts longs into string.static long[]
fromString(CharSequence chars)
Returns thelong
value.static boolean
isValidBase16String(CharSequence value)
Checks if string is valid base16.static long
longFromBase16String(CharSequence chars)
Returns thelong
value whose base16 representation is stored in the first 16 chars ofchars
starting from theoffset
.static void
longToBase16String(long value, char[] dest, int destOffset)
-
-
-
Method Detail
-
fromString
public static long[] fromString(CharSequence chars)
Returns thelong
value.- Parameters:
chars
- the base8 or base16 representation of thelong
.- Returns:
- long array from string. Either contains high and low or just low trace id
-
longFromBase16String
public static long longFromBase16String(CharSequence chars)
Returns thelong
value whose base16 representation is stored in the first 16 chars ofchars
starting from theoffset
.- Parameters:
chars
- the base16 representation of thelong
.- Returns:
- long value from string
-
byteFromBase16String
public static byte byteFromBase16String(CharSequence chars, int offset)
Decodes the specified two character sequence, and returns the resultingbyte
.- Parameters:
chars
- the character sequence to be decoded.offset
- the starting offset in theCharSequence
.- Returns:
- the resulting
byte
- Throws:
IllegalArgumentException
- if the input is not a valid encoded string according to this encoding.
-
isValidBase16String
public static boolean isValidBase16String(CharSequence value)
Checks if string is valid base16.- Parameters:
value
- to check- Returns:
true
if valid base16 string
-
fromLong
public static String fromLong(long id)
Converts long into string.- Parameters:
id
- 64 bit- Returns:
- string representation of the long
-
fromLongs
public static String fromLongs(long idHigh, long idLow)
Converts longs into string.- Parameters:
idHigh
- - trace id high partidLow
- - trace id low part- Returns:
- string representation of the long
-
longToBase16String
public static void longToBase16String(long value, char[] dest, int destOffset)
-
byteToBase16
public static void byteToBase16(byte value, char[] dest, int destOffset)
-
-