Class ByteUtil
java.lang.Object
org.apache.activemq.artemis.utils.ByteUtil
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringbytesToHex(byte[] bytes) static StringbytesToHex(byte[] bytes, int groupSize) static intbytesToInt(byte[] b) static longbytesToLong(byte[] b) static StringbyteToChar(byte value) static longconvertTextBytes(String text) static StringdebugByteArray(byte[] byteArray) Simplify reading of a byte array in a programmers understable waystatic voiddebugFrame(Logger logger, String message, io.netty.buffer.ByteBuf byteIn) static byte[]doubleLongToBytes(long value1, long value2) static voidensureExactWritable(io.netty.buffer.ByteBuf buffer, int minWritableBytes) This ensure a more exact resizing thenByteBuf.ensureWritable(int), if needed.static booleanequals(byte[] left, byte[] right) static booleanequals(byte[] left, byte[] right, int rightOffset, int rightLength) static booleanequals(byte[] bytes, io.netty.buffer.ByteBuf byteBuf, int offset, int length) Returnstrueif theSimpleStringencoded content intobytesis equals tosfalseotherwise. It assumes that thebytescontent is read usingSimpleString.readSimpleString(ByteBuf, int)ie starting right after the length field..static StringformatGroup(String str, int groupSize, int lineBreak) static StringgetHumanReadableByteCount(long bytes) static inthashCode(byte[] bytes) static byte[]hexToBytes(String hexStr) static intintFromBytes(byte b1, byte b2, byte b3, byte b4) static final byte[]intToBytes(int value) static byte[]longToBytes(long value) static voidlongToBytes(long x, byte[] output, int offset) static Stringstatic voidstatic StringreadLine(ActiveMQBuffer buffer) static StringtoSimpleString(byte[] bytes) static voidzeros(ByteBuffer buffer) It zeroes the wholeBuffer.capacity()of the givenbuffer.static voidzeros(ByteBuffer buffer, int offset, int bytes) It zeroesbytesof the givenbuffer, starting (inclusive) fromoffset.
-
Field Details
-
NON_ASCII_STRING
- See Also:
-
-
Constructor Details
-
ByteUtil
public ByteUtil()
-
-
Method Details
-
debugFrame
-
outFrame
-
formatGroup
-
maxString
-
bytesToHex
-
debugByteArray
Simplify reading of a byte array in a programmers understable way -
byteToChar
-
bytesToHex
-
toSimpleString
-
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
-
readLine
-
convertTextBytes
-
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 thenByteBuf.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) Returnstrueif theSimpleStringencoded content intobytesis equals tosfalseotherwise.It assumes that the
bytescontent is read usingSimpleString.readSimpleString(ByteBuf, int)ie starting right after the length field..- Returns:
trueif theSimpleStringencoded content intobytesis equals tosfalseotherwise.It assumes that the
bytescontent is read usingSimpleString.readSimpleString(ByteBuf, int)ie starting right after the length field.
-
intFromBytes
public static int intFromBytes(byte b1, byte b2, byte b3, byte b4) -
zeros
It zeroes the wholeBuffer.capacity()of the givenbuffer.- Throws:
ReadOnlyBufferException- ifbufferis read-only
-
zeros
It zeroesbytesof the givenbuffer, starting (inclusive) fromoffset.- Throws:
IndexOutOfBoundsException- ifoffset + bytes >Buffer.capacity()oroffset >=Buffer.capacity()IllegalArgumentException- ifoffsetorcapacityare less then 0ReadOnlyBufferException- ifbufferis read-only
-
getHumanReadableByteCount
-