Top Description Inners Fields Constructors Methods
io.micrometer.tracing.internal

public final Class EncodingUtils

extends Object
Class Inheritance
Imports
java.util.Arrays

Adopted from OpenTelemetry API.
Author
Marcin Grzejszczak
Since
1.0.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
private static final String
private static final int
pack-priv static final int
private static final ThreadLocal<char[]>
private static final byte[]
private static final char[]
pack-priv static final int
pack-priv static final int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static byte[]
private static char[]
public static byte

Returns:

the resulting byte
byteFromBase16String
(CharSequence
the character sequence to be decoded
chars
,
int
the starting offset in the CharSequence.
offset
)

Decodes the specified two character sequence, and returns the resulting byte.

public static void
byteToBase16(byte
value to convert
value
,
char[]
destination array
dest
,
int
offset
destOffset
)

Converts the byte to base16 string.

private static byte
decodeByte(char hi, char lo)

public static String

Returns:

string representation of the long
fromLong
(long
64 bit
id
)

Converts long into string.

public static String

Returns:

string representation of the long
fromLongs
(long
- trace id high part
idHigh
,
long
- trace id low part
idLow
)

Converts longs into string.

public static long[]

Returns:

long array from string. Either contains high and low or just low trace id
fromString
(CharSequence
the base8 or base16 representation of the long
chars
)

Returns the long value.

private static char[]
private static boolean
isDigit(char b)

private static boolean
private static void
isTrue(boolean expression, String text)

public static boolean

Returns:

true if valid base16 string
isValidBase16String
(CharSequence
to check
value
)

Checks if string is valid base16.

public static long

Returns:

long value from string
longFromBase16String
(CharSequence
the base16 representation of the long
chars
)

Returns the long value whose base16 representation is stored in the first 16 chars of chars starting from the offset.

pack-priv static long

Returns:

long from base16 string
longFromBase16String
(CharSequence
the base16 representation of the long
chars
,
int offset)

Returns the long value whose base16 representation is stored in the first 16 chars of chars starting from the offset.

public static void
longToBase16String(long
value to convert
value
,
char[]
destination array
dest
,
int
offset
destOffset
)

Converts the long to base16 string.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ALPHABETback to summary
private static final String ALPHABET
ASCII_CHARACTERSback to summary
private static final int ASCII_CHARACTERS
BYTE_BASE16back to summary
pack-priv static final int BYTE_BASE16
charBufferback to summary
private static final ThreadLocal<char[]> charBuffer
Annotations
@SuppressWarnings:unchecked
DECODINGback to summary
private static final byte[] DECODING
ENCODINGback to summary
private static final char[] ENCODING
LONG_BASE16back to summary
pack-priv static final int LONG_BASE16
LONG_BYTESback to summary
pack-priv static final int LONG_BYTES

Constructor Detail

EncodingUtilsback to summary
private EncodingUtils()

Method Detail

buildDecodingArrayback to summary
private static byte[] buildDecodingArray()
buildEncodingArrayback to summary
private static char[] buildEncodingArray()
byteFromBase16Stringback to summary
public static byte byteFromBase16String(CharSequence chars, int offset)

Decodes the specified two character sequence, and returns the resulting byte.

Parameters
chars:CharSequence

the character sequence to be decoded

offset:int

the starting offset in the CharSequence.

Returns:byte

the resulting byte

Exceptions
IllegalArgumentException:
if the input is not a valid encoded string according to this encoding
byteToBase16back to summary
public static void byteToBase16(byte value, char[] dest, int destOffset)

Converts the byte to base16 string.

Parameters
value:byte

value to convert

dest:char[]

destination array

destOffset:int

offset

decodeByteback to summary
private static byte decodeByte(char hi, char lo)
fromLongback to summary
public static String fromLong(long id)

Converts long into string.

Parameters
id:long

64 bit

Returns:String

string representation of the long

fromLongsback to summary
public static String fromLongs(long idHigh, long idLow)

Converts longs into string.

Parameters
idHigh:long

- trace id high part

idLow:long

- trace id low part

Returns:String

string representation of the long

fromStringback to summary
public static long[] fromString(CharSequence chars)

Returns the long value.

Parameters
chars:CharSequence

the base8 or base16 representation of the long

Returns:long[]

long array from string. Either contains high and low or just low trace id

getTemporaryBufferback to summary
private static char[] getTemporaryBuffer()
isDigitback to summary
private static boolean isDigit(char b)
isLowercaseHexCharacterback to summary
private static boolean isLowercaseHexCharacter(char b)
isTrueback to summary
private static void isTrue(boolean expression, String text)
isValidBase16Stringback to summary
public static boolean isValidBase16String(CharSequence value)

Checks if string is valid base16.

Parameters
value:CharSequence

to check

Returns:boolean

true if valid base16 string

longFromBase16Stringback to summary
public static long longFromBase16String(CharSequence chars)

Returns the long value whose base16 representation is stored in the first 16 chars of chars starting from the offset.

Parameters
chars:CharSequence

the base16 representation of the long

Returns:long

long value from string

longFromBase16Stringback to summary
pack-priv static long longFromBase16String(CharSequence chars, int offset)

Returns the long value whose base16 representation is stored in the first 16 chars of chars starting from the offset.

Parameters
chars:CharSequence

the base16 representation of the long

Returns:long

long from base16 string

longToBase16Stringback to summary
public static void longToBase16String(long value, char[] dest, int destOffset)

Converts the long to base16 string.

Parameters
value:long

value to convert

dest:char[]

destination array

destOffset:int

offset

io.micrometer.tracing.internal back to summary

pack-priv final Class EncodingUtils.HexCodec

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv static final char[]

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static long
lenientLowerHexToUnsignedLong(CharSequence
the sequence that contains a lower-hex encoded unsigned long.
value
,
int
the inclusive begin index: index of the first lower-hex character representing the unsigned long.
beginIndex
,
int
the exclusive end index: index after the last lower-hex character representing the unsigned long.
endIndex
)

Parses a 16 character lower-hex string with no prefix into an unsigned long, starting at the specified index., but returns zero on invalid input.

pack-priv static String
toLowerHex(long v)

Inspired by okio.Buffer.writeLong.

pack-priv static void
writeHexByte(char[] data, int pos, byte b)

pack-priv static void
writeHexLong(char[] data, int pos, long v)

Inspired by okio.Buffer.writeLong.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

HEX_DIGITSback to summary
pack-priv static final char[] HEX_DIGITS

Constructor Detail

HexCodecback to summary
private HexCodec()

Method Detail

lenientLowerHexToUnsignedLongback to summary
pack-priv static long lenientLowerHexToUnsignedLong(CharSequence value, int beginIndex, int endIndex)

Parses a 16 character lower-hex string with no prefix into an unsigned long, starting at the specified index., but returns zero on invalid input.

Parameters
value:CharSequence

the sequence that contains a lower-hex encoded unsigned long.

beginIndex:int

the inclusive begin index: index of the first lower-hex character representing the unsigned long.

endIndex:int

the exclusive end index: index after the last lower-hex character representing the unsigned long.

toLowerHexback to summary
pack-priv static String toLowerHex(long v)

Inspired by okio.Buffer.writeLong.

writeHexByteback to summary
pack-priv static void writeHexByte(char[] data, int pos, byte b)
writeHexLongback to summary
pack-priv static void writeHexLong(char[] data, int pos, long v)

Inspired by okio.Buffer.writeLong.

io.micrometer.tracing.internal back to summary

pack-priv final Class EncodingUtils.RecyclableBuffers

extends Object
Class Inheritance
  • java.lang.Object
  • io.micrometer.tracing.internal.EncodingUtils.RecyclableBuffers

Field Summary

Modifier and TypeField and Description
private static final ThreadLocal<char[]>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static char[]
parseBuffer()

Returns a ThreadLocal reused char[] for use when decoding bytes into an ID hex string.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

PARSE_BUFFERback to summary
private static final ThreadLocal<char[]> PARSE_BUFFER

Constructor Detail

RecyclableBuffersback to summary
private RecyclableBuffers()

Method Detail

parseBufferback to summary
pack-priv static char[] parseBuffer()

Returns a ThreadLocal reused char[] for use when decoding bytes into an ID hex string. The buffer should be immediately copied into a String after decoding within the same method.