|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object | +--HexDumper
The HexDumper class provides a somewhat abstract way of transforming raw
binary data into its ASCII hex value equivalent. It is capable of
dumping an od(1)-like format to a specified PrintStream defaulting to System.out. It also contains methods for
converting a byte[] array into its hex representation.
The formatBytes () static
functions are provided for the convenience of the programmer who wishes
to dump just a few bytes at a time.
The most recent source code for this class is available at its web reference page.
| Field Summary | |
static char[] |
hexcodes
An array of the hex characters in their logical positions for conveniently transforming a four-bit value into its hex code. |
| Constructor Summary | |
HexDumper()
Creates a new HexDumper object which is prepared to dump
to System.out. |
|
HexDumper(java.io.PrintStream stream)
Initializes a HexDumper object to print to an arbitrary
PrintStream. |
|
| Method Summary | |
void |
dumpBytes(byte[] data)
Dumps a byte[] array to the associated PrintStream in a format similar to od(1). |
void |
dumpBytes(byte[] data,
int offset,
int len)
Dumps a specified portion of a byte[] array to the
associated PrintStream in a format similar to
od(1). |
static char[] |
formatBytes(byte[] data)
Formats a given byte[] array as a sequence of ASCII hex
pairs representing the bytes of the array. |
static char[] |
formatBytes(byte[] data,
int offset,
int len)
Formats a portion of a given byte[] array as a sequence
of ASCII hex pairs representing the bytes of the array. |
int |
getCurrentOffset()
Returns this HexDumper object's concept of the current
offset. |
void |
setCurrentOffset(int offset)
Allows the user to specify the offset to be printed for the immediate next byte dumped by this HexDumper object. |
void |
usePersistentOffset(boolean val)
Sets a flag determining whether this HexDumper object
should keep persistent offsets in between calls to
dumpBytes () or not. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
public static final char[] hexcodes
| Constructor Detail |
public HexDumper()
HexDumper object which is prepared to dump
to System.out.public HexDumper(java.io.PrintStream stream)
HexDumper object to print to an arbitrary
PrintStream.stream - PrintStream object to receive
output from this HexDumper| Method Detail |
public static char[] formatBytes(byte[] data)
byte[] array as a sequence of ASCII hex
pairs representing the bytes of the array.data - Binary "string" to turn into a hex sequencechar[] array containing the
formatted data
public static char[] formatBytes(byte[] data,
int offset,
int len)
byte[] array as a sequence
of ASCII hex pairs representing the bytes of the array.data - Binary "string" to turn into a hex sequenceoffset - Offset of the first byte to formatlen - Length in bytes of the portion of the array that
should be hex-ifiedchar[] array containing the
formatted datapublic void dumpBytes(byte[] data)
byte[] array to the associated PrintStream in a format similar to od(1).data - Array of raw bytes to be converted and output
public void dumpBytes(byte[] data,
int offset,
int len)
byte[] array to the
associated PrintStream in a format similar to
od(1).data - Array of raw bytes to be converted and outputoffset - Offset of the first byte of data that
should be outputlen - The number of bytes of data that should
be output in this translationpublic void usePersistentOffset(boolean val)
HexDumper object
should keep persistent offsets in between calls to
dumpBytes () or not. Note that this affects only the
printed offset, and not the offset into any data passed in.val - New truth value determining if persistent offsets
are to be usedpublic void setCurrentOffset(int offset)
HexDumper object. If persistent
offsets are not in use, this function effectively does nothing.offset - Integer value to be used as the next offset; note
that while this is a signed value, it will be
output as raw hex. Thus, a negative value may
indeed make sense here in order to produce very
large offsets.public int getCurrentOffset()
HexDumper object's concept of the current
offset. This is effectively the next address to be printed when more
data is dumped by this object.HexDumper object.
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||