Class ByteUtil


  • public class ByteUtil
    extends Object
    • Constructor Detail

      • ByteUtil

        public ByteUtil()
    • Method Detail

      • debugFrame

        public static void debugFrame​(org.slf4j.Logger logger,
                                      String message,
                                      io.netty.buffer.ByteBuf byteIn)
      • outFrame

        public static void outFrame​(org.slf4j.Logger logger,
                                    String message,
                                    io.netty.buffer.ByteBuf byteIn,
                                    boolean info)
      • formatGroup

        public static String formatGroup​(String str,
                                         int groupSize,
                                         int lineBreak)
      • maxString

        public static String maxString​(String value,
                                       int size)
      • bytesToHex

        public static String bytesToHex​(byte[] bytes)
      • debugByteArray

        public static String debugByteArray​(byte[] byteArray)
        Simplify reading of a byte array in a programmers understable way
      • byteToChar

        public static String byteToChar​(byte value)
      • bytesToHex

        public static String bytesToHex​(byte[] bytes,
                                        int groupSize)
      • toSimpleString

        public static String toSimpleString​(byte[] bytes)
      • intToBytes

        public static final byte[] intToBytes​(int value)
      • bytesToInt

        public static int bytesToInt​(byte[] b)
      • bytesToLong

        public static long bytesToLong​(byte[] b)
      • longToBytes

        public static byte[] longToBytes​(long value)
      • longToBytes

        public static void longToBytes​(long x,
                                       byte[] output,
                                       int offset)
      • doubleLongToBytes

        public static byte[] doubleLongToBytes​(long value1,
                                               long value2)
      • hexToBytes

        public static byte[] hexToBytes​(String hexStr)
      • convertTextBytes

        public static long convertTextBytes​(String text)
      • hashCode

        public static int hashCode​(byte[] bytes)
      • equals

        public static boolean equals​(byte[] left,
                                     byte[] right)
      • equals

        public static boolean equals​(byte[] left,
                                     byte[] right,
                                     int rightOffset,
                                     int rightLength)
      • ensureExactWritable

        public static void ensureExactWritable​(io.netty.buffer.ByteBuf buffer,
                                               int minWritableBytes)
        This ensure a more exact resizing then ByteBuf.ensureWritable(int), if needed.
        It won't try to trim a large enough buffer.
      • equals

        public static boolean equals​(byte[] bytes,
                                     io.netty.buffer.ByteBuf byteBuf,
                                     int offset,
                                     int length)
        Returns true if the SimpleString encoded content into bytes is equals to s, false otherwise.

        It assumes that the bytes content is read using SimpleString.readSimpleString(ByteBuf, int) ie starting right after the length field.

      • intFromBytes

        public static int intFromBytes​(byte b1,
                                       byte b2,
                                       byte b3,
                                       byte b4)
      • getHumanReadableByteCount

        public static String getHumanReadableByteCount​(long bytes)