@Immutable public final class TraceId extends Object implements Comparable<TraceId>
| Constructor and Description |
|---|
TraceId(long idHi,
long idLo)
Constructs a
TraceId whose representation is specified by two long values representing
the lower and higher parts. |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(TraceId that) |
void |
copyBytesTo(byte[] dest,
int destOffset)
Copies the byte array representations of the
TraceId into the dest beginning at
the destOffset offset. |
void |
copyLowerBase16To(char[] dest,
int destOffset)
Copies the lowercase base16 representations of the
TraceId into the dest
beginning at the destOffset offset. |
boolean |
equals(Object obj) |
static TraceId |
fromBytes(byte[] src,
int srcOffset)
Returns a
TraceId whose representation is copied from the src beginning at the
srcOffset offset. |
static TraceId |
fromLowerBase16(CharSequence src,
int srcOffset)
Returns a
TraceId built from a lowercase base16 representation. |
static TraceId |
getInvalid()
Returns the invalid
TraceId. |
static int |
getSize()
Returns the size in bytes of the
TraceId. |
long |
getTraceRandomPart()
Returns the rightmost 8 bytes of the trace-id as a long value.
|
int |
hashCode() |
boolean |
isValid()
Returns whether the
TraceId is valid. |
String |
toLowerBase16()
Returns the lowercase base16 encoding of this
TraceId. |
String |
toString() |
public TraceId(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 fromBytes(byte[], int) with the specified values
stored as big-endian.
idHi - the higher part of the TraceId.idLo - the lower part of the TraceId.public static int getSize()
TraceId.TraceId.public static TraceId getInvalid()
TraceId. All bytes are '\0'.TraceId.public static TraceId fromBytes(byte[] src, int srcOffset)
TraceId whose representation is copied from the src beginning at the
srcOffset offset.src - the buffer where the representation of the TraceId is copied.srcOffset - the offset in the buffer where the representation of the TraceId
begins.TraceId whose representation is copied from the buffer.NullPointerException - if src is null.IndexOutOfBoundsException - if srcOffset+TraceId.getSize() is greater than src.length.public void copyBytesTo(byte[] dest,
int destOffset)
TraceId into the dest beginning at
the destOffset offset.dest - the destination buffer.destOffset - the starting offset in the destination buffer.NullPointerException - if dest is null.IndexOutOfBoundsException - if destOffset+TraceId.getSize() is greater than
dest.length.public static TraceId fromLowerBase16(CharSequence 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.NullPointerException - if src is null.IllegalArgumentException - if not enough characters in the src from the srcOffset.public void copyLowerBase16To(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.IndexOutOfBoundsException - if destOffset + 2 * TraceId.getSize() is greater than
dest.length.public boolean isValid()
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 String toLowerBase16()
TraceId.TraceId.public long getTraceRandomPart()
This method is marked as internal and subject to change.
public int compareTo(TraceId that)
compareTo in interface Comparable<TraceId>