Package org.agrona
Class PrintBufferUtil
java.lang.Object
org.agrona.PrintBufferUtil
Useful utils to hex dump the Agrona's buffers.
This is code adapted from the Netty project adopted to support DirectBuffer.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidappendPrettyHexDump(StringBuilder dump, DirectBuffer buffer) Appends the prettified multi-line hexadecimal dump of the specifiedDirectBufferto the specifiedStringBuilderthat is easy to read by humans.static voidappendPrettyHexDump(StringBuilder dump, DirectBuffer buffer, int offset, int length) Appends the prettified multi-line hexadecimal dump of the specifiedDirectBufferto the specifiedStringBuilderthat is easy to read by humans, starting at the givenoffsetusing the givenlength.static StringbyteToHexStringPadded(int value) Converts the specified byte value into a 2-digit hexadecimal integer.static StringhexDump(byte[] array) Returns a hex dump of the specified byte array.static StringhexDump(byte[] array, int fromIndex, int length) Returns a hex dump of the specified byte array's subregion.static StringhexDump(DirectBuffer buffer) Returns a hex dump of the specified buffer's readable bytes.static StringhexDump(DirectBuffer buffer, int fromIndex, int length) Returns a hex dump of the specified buffer's subregion.static StringprettyHexDump(DirectBuffer buffer) Returns a hexadecimal dump of the specifiedDirectBufferthat is easy to read by humans.static StringprettyHexDump(DirectBuffer buffer, int offset, int length) Returns a hexadecimal dump of the specifiedDirectBufferthat is easy to read by humans, starting at the givenoffsetusing the givenlength.
-
Method Details
-
hexDump
Returns a hex dump of the specified buffer's readable bytes.- Parameters:
buffer- dumped buffer.- Returns:
- hex dump in a string representation.
-
hexDump
Returns a hex dump of the specified buffer's subregion.- Parameters:
buffer- dumped buffer.fromIndex- where should we start to print.length- how much should we print.- Returns:
- hex dump in a string representation.
-
hexDump
Returns a hex dump of the specified byte array.- Parameters:
array- dumped array.- Returns:
- hex dump in a string representation.
-
hexDump
Returns a hex dump of the specified byte array's subregion.- Parameters:
array- dumped array.fromIndex- where should we start to print.length- how much should we print.- Returns:
- hex dump in a string representation.
-
prettyHexDump
Returns a hexadecimal dump of the specifiedDirectBufferthat is easy to read by humans.- Parameters:
buffer- dumped buffer.- Returns:
- pretty hex dump in a string representation.
-
prettyHexDump
Returns a hexadecimal dump of the specifiedDirectBufferthat is easy to read by humans, starting at the givenoffsetusing the givenlength.- Parameters:
buffer- dumped buffer.offset- where should we start to print.length- how much should we print.- Returns:
- pretty hex dump in a string representation.
-
appendPrettyHexDump
Appends the prettified multi-line hexadecimal dump of the specifiedDirectBufferto the specifiedStringBuilderthat is easy to read by humans.- Parameters:
dump- where should we append string representation of the buffer.buffer- dumped buffer.
-
appendPrettyHexDump
public static void appendPrettyHexDump(StringBuilder dump, DirectBuffer buffer, int offset, int length) Appends the prettified multi-line hexadecimal dump of the specifiedDirectBufferto the specifiedStringBuilderthat is easy to read by humans, starting at the givenoffsetusing the givenlength.- Parameters:
dump- where should we append string representation of the buffer.buffer- dumped buffer.offset- where should we start to print.length- how much should we print.
-
byteToHexStringPadded
Converts the specified byte value into a 2-digit hexadecimal integer.- Parameters:
value- converted value.- Returns:
- hex representation of the value.
-