Class ByteUtil

java.lang.Object
org.apache.activemq.artemis.utils.ByteUtil

public class ByteUtil extends Object
  • Field Details

  • Constructor Details

    • ByteUtil

      public ByteUtil()
  • Method Details

    • debugFrame

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

      public static void outFrame(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)
    • readLine

      public static String readLine(ActiveMQBuffer buffer)
    • 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..

      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)
    • zeros

      public static void zeros(ByteBuffer buffer)
      It zeroes the whole Buffer.capacity() of the given buffer.
      Throws:
      ReadOnlyBufferException - if buffer is read-only
    • zeros

      public static void zeros(ByteBuffer buffer, int offset, int bytes)
      It zeroes bytes of the given buffer, starting (inclusive) from offset.
      Throws:
      IndexOutOfBoundsException - if offset + bytes > Buffer.capacity() or offset >= Buffer.capacity()
      IllegalArgumentException - if offset or capacity are less then 0
      ReadOnlyBufferException - if buffer is read-only
    • getHumanReadableByteCount

      public static String getHumanReadableByteCount(long bytes)