Class GridClientByteUtils


  • public abstract class GridClientByteUtils
    extends Object
    Primitive to byte array and backward conversions.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int bytesToInt​(byte[] bytes, int off)
      Constructs int from byte array.
      static long bytesToLong​(byte[] bytes, int off)
      Constructs long from byte array.
      static short bytesToShort​(byte[] bytes, int off)
      Constructs short from byte array.
      static UUID bytesToUuid​(byte[] bytes, int off)
      Constructs UUID from byte array.
      static byte[] intToBytes​(int i)
      Converts primitive int type to byte array.
      static int intToBytes​(int i, byte[] bytes, int off)
      Converts primitive int type to byte array and stores it in specified byte array.
      static byte[] longToBytes​(long l)
      Converts primitive long type to byte array.
      static int longToBytes​(long l, byte[] bytes, int off)
      Converts primitive long type to byte array and stores it in specified byte array.
      static byte[] shortToBytes​(short s)
      Converts primitive short type to byte array.
      static int shortToBytes​(short s, byte[] bytes, int off)
      Converts primitive short type to byte array and stores it in specified byte array.
      static byte[] uuidToBytes​(UUID uuid)
      Converts an UUID to byte array.
      static int uuidToBytes​(UUID uuid, byte[] bytes, int off)
      Converts UUID type to byte array and stores it in specified byte array.
    • Constructor Detail

      • GridClientByteUtils

        public GridClientByteUtils()
    • Method Detail

      • shortToBytes

        public static byte[] shortToBytes​(short s)
        Converts primitive short type to byte array.
        Parameters:
        s - Short value.
        Returns:
        Array of bytes.
      • intToBytes

        public static byte[] intToBytes​(int i)
        Converts primitive int type to byte array.
        Parameters:
        i - Integer value.
        Returns:
        Array of bytes.
      • longToBytes

        public static byte[] longToBytes​(long l)
        Converts primitive long type to byte array.
        Parameters:
        l - Long value.
        Returns:
        Array of bytes.
      • shortToBytes

        public static int shortToBytes​(short s,
                                       byte[] bytes,
                                       int off)
        Converts primitive short type to byte array and stores it in specified byte array.
        Parameters:
        s - Short value.
        bytes - Array of bytes.
        off - Offset in bytes array.
        Returns:
        Number of bytes overwritten in bytes array.
      • intToBytes

        public static int intToBytes​(int i,
                                     byte[] bytes,
                                     int off)
        Converts primitive int type to byte array and stores it in specified byte array.
        Parameters:
        i - Integer value.
        bytes - Array of bytes.
        off - Offset in bytes array.
        Returns:
        Number of bytes overwritten in bytes array.
      • longToBytes

        public static int longToBytes​(long l,
                                      byte[] bytes,
                                      int off)
        Converts primitive long type to byte array and stores it in specified byte array.
        Parameters:
        l - Long value.
        bytes - Array of bytes.
        off - Offset in bytes array.
        Returns:
        Number of bytes overwritten in bytes array.
      • uuidToBytes

        public static byte[] uuidToBytes​(UUID uuid)
        Converts an UUID to byte array.
        Parameters:
        uuid - UUID value.
        Returns:
        Encoded into byte array UUID.
      • uuidToBytes

        public static int uuidToBytes​(UUID uuid,
                                      byte[] bytes,
                                      int off)
        Converts UUID type to byte array and stores it in specified byte array.
        Parameters:
        uuid - UUID to convert.
        bytes - Array of bytes.
        off - Offset in bytes array.
        Returns:
        Number of bytes overwritten in bytes array.
      • bytesToShort

        public static short bytesToShort​(byte[] bytes,
                                         int off)
        Constructs short from byte array.
        Parameters:
        bytes - Array of bytes.
        off - Offset in bytes array.
        Returns:
        Short value.
      • bytesToInt

        public static int bytesToInt​(byte[] bytes,
                                     int off)
        Constructs int from byte array.
        Parameters:
        bytes - Array of bytes.
        off - Offset in bytes array.
        Returns:
        Integer value.
      • bytesToLong

        public static long bytesToLong​(byte[] bytes,
                                       int off)
        Constructs long from byte array.
        Parameters:
        bytes - Array of bytes.
        off - Offset in bytes array.
        Returns:
        Long value.
      • bytesToUuid

        public static UUID bytesToUuid​(byte[] bytes,
                                       int off)
        Constructs UUID from byte array.
        Parameters:
        bytes - Array of bytes.
        off - Offset in bytes array.
        Returns:
        UUID value.