Package io.opencensus.trace
Class BigendianEncoding
java.lang.Object
io.opencensus.trace.BigendianEncoding
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private static final int
(package private) static final int
private static final byte[]
private static final char[]
(package private) static final int
(package private) static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static byte[]
private static char[]
(package private) static byte
byteFromBase16String
(CharSequence chars, int offset) Decodes the specified two character sequence, and returns the resultingbyte
.private static void
byteToBase16
(byte value, char[] dest, int destOffset) (package private) static void
byteToBase16String
(byte value, char[] dest, int destOffset) Encodes the specified byte, and returns the encodedString
.private static byte
decodeByte
(char hi, char lo) (package private) static long
longFromBase16String
(CharSequence chars, int offset) Returns thelong
value whose base16 representation is stored in the first 16 chars ofchars
starting from theoffset
.(package private) static long
longFromByteArray
(byte[] bytes, int offset) Returns thelong
value whose big-endian representation is stored in the first 8 bytes ofbytes
starting from theoffset
.(package private) static void
longToBase16String
(long value, char[] dest, int destOffset) Appends the base16 encoding of the specifiedvalue
to thedest
.(package private) static void
longToByteArray
(long value, byte[] dest, int destOffset) Stores the big-endian representation ofvalue
in thedest
starting from thedestOffset
.
-
Field Details
-
LONG_BYTES
static final int LONG_BYTES- See Also:
-
BYTE_BASE16
static final int BYTE_BASE16- See Also:
-
LONG_BASE16
static final int LONG_BASE16- See Also:
-
ALPHABET
- See Also:
-
ASCII_CHARACTERS
private static final int ASCII_CHARACTERS- See Also:
-
ENCODING
private static final char[] ENCODING -
DECODING
private static final byte[] DECODING
-
-
Constructor Details
-
BigendianEncoding
private BigendianEncoding()
-
-
Method Details
-
buildEncodingArray
private static char[] buildEncodingArray() -
buildDecodingArray
private static byte[] buildDecodingArray() -
longFromByteArray
static long longFromByteArray(byte[] bytes, int offset) Returns thelong
value whose big-endian representation is stored in the first 8 bytes ofbytes
starting from theoffset
.- Parameters:
bytes
- the byte array representation of thelong
.offset
- the starting offset in the byte array.- Returns:
- the
long
value whose big-endian representation is given. - Throws:
IllegalArgumentException
- ifbytes
has fewer than 8 elements.
-
longToByteArray
static void longToByteArray(long value, byte[] dest, int destOffset) Stores the big-endian representation ofvalue
in thedest
starting from thedestOffset
.- Parameters:
value
- the value to be converted.dest
- the destination byte array.destOffset
- the starting offset in the destination byte array.
-
longFromBase16String
Returns thelong
value whose base16 representation is stored in the first 16 chars ofchars
starting from theoffset
.- Parameters:
chars
- the base16 representation of thelong
.offset
- the starting offset in theCharSequence
.
-
longToBase16String
static void longToBase16String(long value, char[] dest, int destOffset) Appends the base16 encoding of the specifiedvalue
to thedest
.- Parameters:
value
- the value to be converted.dest
- the destination char array.destOffset
- the starting offset in the destination char array.
-
byteToBase16String
static void byteToBase16String(byte value, char[] dest, int destOffset) Encodes the specified byte, and returns the encodedString
.- Parameters:
value
- the value to be converted.dest
- the destination char array.destOffset
- the starting offset in the destination char array.
-
byteFromBase16String
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.
-
decodeByte
private static byte decodeByte(char hi, char lo) -
byteToBase16
private static void byteToBase16(byte value, char[] dest, int destOffset)
-