java.lang.Object
one.tomorrow.transactionaloutbox.commons.Longs

public class Longs extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte[]
    toByteArray(long data)
    Returns a big-endian representation of value in an 8-element byte array; equivalent to ByteBuffer.allocate(8).putLong(value).array().
    For example, the input value 0x1213141516171819L would yield the byte array {0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19}.
    static long
    toLong(byte[] data)
    Returns the long value whose big-endian representation is stored in the given byte array (length must be 8); equivalent to ByteBuffer.wrap(bytes).getLong().
    For example, the input byte array {0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19} would yield the long value 0x1213141516171819L.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Longs

      public Longs()
  • Method Details

    • toByteArray

      public static byte[] toByteArray(long data)
      Returns a big-endian representation of value in an 8-element byte array; equivalent to ByteBuffer.allocate(8).putLong(value).array().
      For example, the input value 0x1213141516171819L would yield the byte array {0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19}.
    • toLong

      public static long toLong(byte[] data)
      Returns the long value whose big-endian representation is stored in the given byte array (length must be 8); equivalent to ByteBuffer.wrap(bytes).getLong().
      For example, the input byte array {0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19} would yield the long value 0x1213141516171819L.
      Parameters:
      data - array of 8 bytes, the big-endian representation of the long
      Returns:
      the long value
      Throws:
      IllegalArgumentException - if data is null or has length != 8.