Class CoderTools


  • public class CoderTools
    extends Object
    Byte en/decoding tools
    Author:
    kuhn
    • Constructor Summary

      Constructors 
      Constructor Description
      CoderTools()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] getByteArray​(byte[] data, int offset)
      Get all remaining bytes from byte array
      static byte[] getByteArray​(byte[] data, int offset, int length)
      Get a number of bytes from byte array
      static int getInt16​(byte[] data, int offset)
      Get a uint16 from a byte array with offset, MSB is first bit
      static int getInt32​(byte[] data, int offset)
      Get a uint32 from a byte array with offset, MSB is first bit
      static int getInt8​(byte[] data, int offset)
      Get a uint8 from a byte array with offset, MSB is first bit
      static String getString​(byte[] data, int offset)
      Extract a string from a byte array
      static byte[] setByteArray​(byte[] data, int offset, byte[] newValue)
      Copy bytes to byte array
      static byte[] setByteArray​(byte[] data, int offset, byte[] newValue, int len)
      Copy bytes to byte array
      static byte[] setInt16​(byte[] data, int offset, int value)
      Copy an uint16 to a byte array at given offset, MSB is first bit
      static byte[] setInt32​(byte[] data, int offset, int value)
      Copy an uint32 to a byte array at given offset, MSB is first bit
      static byte[] setInt8​(byte[] data, int offset, int value)
      Copy an uint8 to a byte array at given offset, MSB is first bit
      static byte[] setString​(byte[] data, int offset, String newValue)
      Put a string into a byte array
    • Constructor Detail

      • CoderTools

        public CoderTools()
    • Method Detail

      • getInt32

        public static int getInt32​(byte[] data,
                                   int offset)
        Get a uint32 from a byte array with offset, MSB is first bit
      • setInt32

        public static byte[] setInt32​(byte[] data,
                                      int offset,
                                      int value)
        Copy an uint32 to a byte array at given offset, MSB is first bit
      • getInt16

        public static int getInt16​(byte[] data,
                                   int offset)
        Get a uint16 from a byte array with offset, MSB is first bit
      • setInt16

        public static byte[] setInt16​(byte[] data,
                                      int offset,
                                      int value)
        Copy an uint16 to a byte array at given offset, MSB is first bit
      • getInt8

        public static int getInt8​(byte[] data,
                                  int offset)
        Get a uint8 from a byte array with offset, MSB is first bit
      • setInt8

        public static byte[] setInt8​(byte[] data,
                                     int offset,
                                     int value)
        Copy an uint8 to a byte array at given offset, MSB is first bit
      • getByteArray

        public static byte[] getByteArray​(byte[] data,
                                          int offset)
        Get all remaining bytes from byte array
      • getByteArray

        public static byte[] getByteArray​(byte[] data,
                                          int offset,
                                          int length)
        Get a number of bytes from byte array
      • setByteArray

        public static byte[] setByteArray​(byte[] data,
                                          int offset,
                                          byte[] newValue)
        Copy bytes to byte array
      • setByteArray

        public static byte[] setByteArray​(byte[] data,
                                          int offset,
                                          byte[] newValue,
                                          int len)
        Copy bytes to byte array
      • getString

        public static String getString​(byte[] data,
                                       int offset)
        Extract a string from a byte array
      • setString

        public static byte[] setString​(byte[] data,
                                       int offset,
                                       String newValue)
        Put a string into a byte array