public final class DumpUtility
extends java.lang.Object
Buffer instances.
Each instance of this class tracks the buffers it dumps and does not dump the same buffer more than once. Because of this, an instance of this class should not be retained beyond actual need to avoid interfering with garbage collection of the dumped buffers.
Buffer implementations.
Operation of the following methods requires this access:
| Modifier and Type | Class and Description |
|---|---|
static class |
DumpUtility.FieldInaccessibleException
Thrown if reflective access to a required internal field fails.
|
| Constructor and Description |
|---|
DumpUtility(java.io.PrintStream printStream)
Constructs a new
DumpUtility using the PrintStream provided. |
DumpUtility(java.io.PrintStream printStream,
java.lang.CharSequence linePrefix)
Constructs a new
DumpUtility using the PrintStream and line prefix provided. |
| Modifier and Type | Method and Description |
|---|---|
void |
dump(byte[] bytes)
Writes the contents of
byte[] to the PrintStream
provided. |
void |
dumpBuffer(java.nio.ByteBuffer buffer)
Writes the contents of
ByteBuffer to the PrintStream
provided. |
static void |
dumpBuffer(java.nio.ByteBuffer buffer,
java.io.PrintStream printStream)
A convenience method that allocates a
DumpUtility instance, dumps a buffer,
and discards the DumpUtility instance. |
void |
dumpBuffer(java.nio.IntBuffer buffer)
Attempts to dump a
IntBuffer. |
static void |
dumpBuffer(java.nio.IntBuffer buffer,
java.io.PrintStream printStream)
A convenience method that allocates a
DumpUtility instance, dumps a buffer,
and discards the DumpUtility instance. |
void |
dumpBuffer(java.nio.LongBuffer buffer)
Attempts to dump a
LongBuffer. |
static void |
dumpBuffer(java.nio.LongBuffer buffer,
java.io.PrintStream printStream)
A convenience method that allocates a
DumpUtility instance, dumps a buffer,
and discards the DumpUtility instance. |
public DumpUtility(java.io.PrintStream printStream)
DumpUtility using the PrintStream provided.
This constructor is equivalent to
new DumpUtility(printStream, "").printStream - the PrintStream to which the dump is writtenpublic DumpUtility(java.io.PrintStream printStream,
java.lang.CharSequence linePrefix)
DumpUtility using the PrintStream and line prefix provided.printStream - the PrintStream to which the dump is writtenlinePrefix - the value to prepend to each dump line writtenpublic static void dumpBuffer(java.nio.IntBuffer buffer,
java.io.PrintStream printStream)
DumpUtility instance, dumps a buffer,
and discards the DumpUtility instance.buffer - the IntBuffer to dumpprintStream - the PrintStream to which the dump is writtenjava.lang.UnsupportedOperationException - if the buffer is not a supported type or
reflective access to a required field failspublic static void dumpBuffer(java.nio.LongBuffer buffer,
java.io.PrintStream printStream)
DumpUtility instance, dumps a buffer,
and discards the DumpUtility instance.buffer - the LongBuffer to dumpprintStream - the PrintStream to which the dump is writtenjava.lang.UnsupportedOperationException - if the buffer is not a supported type or
reflective access to a required field failspublic static void dumpBuffer(java.nio.ByteBuffer buffer,
java.io.PrintStream printStream)
DumpUtility instance, dumps a buffer,
and discards the DumpUtility instance.buffer - the ByteBuffer to dumpprintStream - the PrintStream to which the dump is writtenpublic void dumpBuffer(java.nio.IntBuffer buffer)
IntBuffer. The present implementation of this
method depends the use of ByteBuffer.asIntBuffer in
creation of buffer and on the internal implementation of ByteBuffer.buffer - the IntBuffer instance to dumpjava.lang.UnsupportedOperationException - if the buffer is not a supported type or
reflective access to a required field failspublic void dumpBuffer(java.nio.LongBuffer buffer)
LongBuffer. The present implementation of this
method depends the use of ByteBuffer.asLongBuffer in
creation of buffer and on the internal implementation of ByteBuffer.buffer - the LongBuffer instance to dumpjava.lang.UnsupportedOperationException - if the buffer is not a supported type or
reflective access to a required field failspublic void dumpBuffer(java.nio.ByteBuffer buffer)
ByteBuffer to the PrintStream
provided. The dump consists of a sequence of lines where each line is the dump of a 32-byte segment from
the buffer and includes data in hexadecimal and in printable ASCII. A sample dump is shown:
00000000 00000000 00000000 00000000 00000023 A5000000 00000000 00000000 00000000 *...............# ................*
00000020 00000000 00000020 00000000 00000023 A5000000 00000000 00000000 00000000 *....... .......# ................*
00000040-00000C7F duplicates above * *
00000C80 00000000 00000020 00000000 00000351 00000000 00000000 00000000 00000000 *....... .......Q ................*
00000CA0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 *................ ................*
00000CC0-00FFFFDF duplicates above * *
00FFFFE0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 *................ ................*
For a direct ByteBuffer, this method attempts to access the value of an
internal field. Failure to access this field does not prevent this method from dumping
the ByteBuffer.
buffer - the ByteBuffer to dump; the buffer is printed from position zero (0) through
the buffer limit using a view over the bufferpublic void dump(byte[] bytes)
byte[] to the PrintStream
provided. The dump consists of a sequence of lines where each line is the dump of a 32-byte segment from
the array and includes data in hexadecimal and in printable ASCII. A sample dump is shown:
00000000 00000000 00000000 00000000 00000023 A5000000 00000000 00000000 00000000 *...............# ................*
00000020 00000000 00000020 00000000 00000023 A5000000 00000000 00000000 00000000 *....... .......# ................*
00000040-00000C7F duplicates above * *
00000C80 00000000 00000020 00000000 00000351 00000000 00000000 00000000 00000000 *....... .......Q ................*
00000CA0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 *................ ................*
00000CC0-00FFFFDF duplicates above * *
00FFFFE0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 *................ ................*
bytes - the byte array to dumpCopyright © 2022. All rights reserved.