@Immutable
public final class TraceId
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static byte[] |
bytesFromHex(java.lang.String src,
int srcOffset)
Returns a
TraceId built from a lowercase base16 representation. |
static java.lang.String |
bytesToHex(byte[] traceId)
Returns the lowercase base16 encoding of this
TraceId . |
static void |
copyHexInto(byte[] traceId,
char[] dest,
int destOffset)
Copies the lowercase base16 representations of the
TraceId into the dest
beginning at the destOffset offset. |
static java.lang.String |
fromLongs(long idHi,
long idLo)
Constructs a
TraceId whose representation is specified by two long values representing
the lower and higher parts. |
static int |
getHexLength()
Returns the length of the base16 (hex) representation of the
TraceId . |
static java.lang.String |
getInvalid()
Returns the invalid
TraceId . |
static int |
getSize()
Returns the size in bytes of the
TraceId . |
static long |
getTraceIdRandomPart(java.lang.CharSequence traceId)
Returns the rightmost 8 bytes of the trace-id as a long value.
|
static boolean |
isValid(java.lang.CharSequence traceId)
Returns whether the
TraceId is valid. |
public static int getSize()
TraceId
.TraceId
.public static int getHexLength()
TraceId
.public static java.lang.String getInvalid()
TraceId
. All bytes are '\0'.TraceId
.public static java.lang.String fromLongs(long idHi, long idLo)
TraceId
whose representation is specified by two long values representing
the lower and higher parts.
There is no restriction on the specified values, other than the already established validity
rules applying to TraceId
. Specifying 0 for both values will effectively make the new
TraceId
invalid.
This is equivalent to calling bytesToHex(byte[])
with the specified values stored
as big-endian.
idHi
- the higher part of the TraceId
.idLo
- the lower part of the TraceId
.public static byte[] bytesFromHex(java.lang.String src, int srcOffset)
TraceId
built from a lowercase base16 representation.src
- the lowercase base16 representation.srcOffset
- the offset in the buffer where the representation of the TraceId
begins.TraceId
built from a lowercase base16 representation.java.lang.NullPointerException
- if src
is null.java.lang.IllegalArgumentException
- if not enough characters in the src
from the srcOffset
.public static void copyHexInto(byte[] traceId, char[] dest, int destOffset)
TraceId
into the dest
beginning at the destOffset
offset.dest
- the destination buffer.destOffset
- the starting offset in the destination buffer.java.lang.IndexOutOfBoundsException
- if destOffset + 2 * TraceId.getSize()
is greater than
dest.length
.public static boolean isValid(java.lang.CharSequence traceId)
TraceId
is valid. A valid trace identifier is a 16-byte array with
at least one non-zero byte.true
if the TraceId
is valid.public static java.lang.String bytesToHex(byte[] traceId)
TraceId
.TraceId
.public static long getTraceIdRandomPart(java.lang.CharSequence traceId)
This method is marked as internal and subject to change.