Class SpanId


  • @Immutable
    public final class SpanId
    extends java.lang.Object
    Helper methods for dealing with a span identifier. A valid span identifier is an 8-byte array with at least one non-zero byte. In base-16 representation, a 16 character hex String, where at least one of the characters is not a '0'.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static long asLong​(java.lang.CharSequence src)
      Convert the the given hex spanId into a long representation.
      static byte[] bytesFromHex​(java.lang.String src, int srcOffset)
      Returns a SpanId built from a lowercase base16 representation.
      static java.lang.String bytesToHex​(byte[] spanId)
      Encode the bytes as base-16 (hex), padded with '0's on the left.
      static java.lang.String fromLong​(long id)
      Generate a valid SpanId from the given long value.
      static int getHexLength()
      Returns the length of the base16 (hex) representation of the SpanId.
      static java.lang.String getInvalid()
      Returns the invalid SpanId.
      static int getSize()
      Returns the size in bytes of the SpanId.
      static boolean isValid​(java.lang.String spanId)
      Returns whether the span identifier is valid.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getSize

        public static int getSize()
        Returns the size in bytes of the SpanId.
        Returns:
        the size in bytes of the SpanId.
      • getHexLength

        public static int getHexLength()
        Returns the length of the base16 (hex) representation of the SpanId.
      • getInvalid

        public static java.lang.String getInvalid()
        Returns the invalid SpanId. All bytes are 0.
        Returns:
        the invalid SpanId.
      • fromLong

        public static java.lang.String fromLong​(long id)
        Generate a valid SpanId from the given long value.
      • bytesFromHex

        public static byte[] bytesFromHex​(java.lang.String src,
                                          int srcOffset)
        Returns a SpanId built from a lowercase base16 representation.
        Parameters:
        src - the lowercase base16 representation.
        srcOffset - the offset in the buffer where the representation of the SpanId begins.
        Returns:
        a SpanId built from a lowercase base16 representation.
        Throws:
        java.lang.NullPointerException - if src is null.
        java.lang.IllegalArgumentException - if not enough characters in the src from the srcOffset.
      • isValid

        public static boolean isValid​(java.lang.String spanId)
        Returns whether the span identifier is valid. A valid span identifier is an 8-byte array with at least one non-zero byte.
        Returns:
        true if the span identifier is valid.
      • bytesToHex

        public static java.lang.String bytesToHex​(byte[] spanId)
        Encode the bytes as base-16 (hex), padded with '0's on the left.
      • asLong

        public static long asLong​(java.lang.CharSequence src)
        Convert the the given hex spanId into a long representation.