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
.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
appendPrettyHexDump
(StringBuilder dump, DirectBuffer buffer) Appends the prettified multi-line hexadecimal dump of the specifiedDirectBuffer
to the specifiedStringBuilder
that is easy to read by humans.static void
appendPrettyHexDump
(StringBuilder dump, DirectBuffer buffer, int offset, int length) Appends the prettified multi-line hexadecimal dump of the specifiedDirectBuffer
to the specifiedStringBuilder
that is easy to read by humans, starting at the givenoffset
using the givenlength
.static String
byteToHexStringPadded
(int value) Converts the specified byte value into a 2-digit hexadecimal integer.static String
hexDump
(byte[] array) Returns a hex dump of the specified byte array.static String
hexDump
(byte[] array, int fromIndex, int length) Returns a hex dump of the specified byte array's subregion.static String
hexDump
(DirectBuffer buffer) Returns a hex dump of the specified buffer's readable bytes.static String
hexDump
(DirectBuffer buffer, int fromIndex, int length) Returns a hex dump of the specified buffer's subregion.static String
prettyHexDump
(DirectBuffer buffer) Returns a hexadecimal dump of the specifiedDirectBuffer
that is easy to read by humans.static String
prettyHexDump
(DirectBuffer buffer, int offset, int length) Returns a hexadecimal dump of the specifiedDirectBuffer
that is easy to read by humans, starting at the givenoffset
using the givenlength
.
-
Field Details
-
NEWLINE
-
EMPTY_STRING
- See Also:
-
BYTE2HEX_PAD
-
-
Constructor Details
-
PrintBufferUtil
private PrintBufferUtil()
-
-
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 specifiedDirectBuffer
that 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 specifiedDirectBuffer
that is easy to read by humans, starting at the givenoffset
using 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 specifiedDirectBuffer
to the specifiedStringBuilder
that 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 specifiedDirectBuffer
to the specifiedStringBuilder
that is easy to read by humans, starting at the givenoffset
using 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.
-