Class ByteUtil
- java.lang.Object
-
- org.apache.activemq.artemis.utils.ByteUtil
-
public class ByteUtil extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringNON_ASCII_STRING
-
Constructor Summary
Constructors Constructor Description ByteUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringbytesToHex(byte[] bytes)static java.lang.StringbytesToHex(byte[] bytes, int groupSize)static intbytesToInt(byte[] b)static longbytesToLong(byte[] b)static java.lang.StringbyteToChar(byte value)static longconvertTextBytes(java.lang.String text)static java.lang.StringdebugByteArray(byte[] byteArray)Simplify reading of a byte array in a programmers understable waystatic voiddebugFrame(org.jboss.logging.Logger logger, java.lang.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.
It won't try to trim a large enough buffer.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)static java.lang.StringformatGroup(java.lang.String str, int groupSize, int lineBreak)static java.lang.StringgetHumanReadableByteCount(long bytes)static inthashCode(byte[] bytes)static byte[]hexToBytes(java.lang.String hexStr)static intintFromBytes(byte b1, byte b2, byte b3, byte b4)static byte[]intToBytes(int value)static byte[]longToBytes(long value)static voidlongToBytes(long x, byte[] output, int offset)static java.lang.StringmaxString(java.lang.String value, int size)static voidoutFrame(org.jboss.logging.Logger logger, java.lang.String message, io.netty.buffer.ByteBuf byteIn, boolean info)static java.lang.StringreadLine(ActiveMQBuffer buffer)static java.lang.StringtoSimpleString(byte[] bytes)static voidzeros(java.nio.ByteBuffer buffer)It zeroes the wholeBuffer.capacity()of the givenbuffer.static voidzeros(java.nio.ByteBuffer buffer, int offset, int bytes)It zeroesbytesof the givenbuffer, starting (inclusive) fromoffset.
-
-
-
Field Detail
-
NON_ASCII_STRING
public static final java.lang.String NON_ASCII_STRING
- See Also:
- Constant Field Values
-
-
Method Detail
-
debugFrame
public static void debugFrame(org.jboss.logging.Logger logger, java.lang.String message, io.netty.buffer.ByteBuf byteIn)
-
outFrame
public static void outFrame(org.jboss.logging.Logger logger, java.lang.String message, io.netty.buffer.ByteBuf byteIn, boolean info)
-
formatGroup
public static java.lang.String formatGroup(java.lang.String str, int groupSize, int lineBreak)
-
maxString
public static java.lang.String maxString(java.lang.String value, int size)
-
bytesToHex
public static java.lang.String bytesToHex(byte[] bytes)
-
debugByteArray
public static java.lang.String debugByteArray(byte[] byteArray)
Simplify reading of a byte array in a programmers understable way
-
byteToChar
public static java.lang.String byteToChar(byte value)
-
bytesToHex
public static java.lang.String bytesToHex(byte[] bytes, int groupSize)
-
toSimpleString
public static java.lang.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(java.lang.String hexStr)
-
readLine
public static java.lang.String readLine(ActiveMQBuffer buffer)
-
convertTextBytes
public static long convertTextBytes(java.lang.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 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 tos,falseotherwise.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
public static void zeros(java.nio.ByteBuffer buffer)
It zeroes the wholeBuffer.capacity()of the givenbuffer.- Throws:
java.nio.ReadOnlyBufferException- ifbufferis read-only
-
zeros
public static void zeros(java.nio.ByteBuffer buffer, int offset, int bytes)It zeroesbytesof the givenbuffer, starting (inclusive) fromoffset.- Throws:
java.lang.IndexOutOfBoundsException- ifoffset + bytes >Buffer.capacity()oroffset >=Buffer.capacity()java.lang.IllegalArgumentException- ifoffsetorcapacityare less then 0java.nio.ReadOnlyBufferException- ifbufferis read-only
-
getHumanReadableByteCount
public static java.lang.String getHumanReadableByteCount(long bytes)
-
-