com.claritysys.util
Class Hexadecimal

java.lang.Object
  extended by com.claritysys.util.Hexadecimal

public final class Hexadecimal
extends java.lang.Object

Provides methods for dumping binary data to a console display.

The class is composed of static methods, and, unfortunately, a static buffer. Thus it is not thread-safe.


Constructor Summary
Hexadecimal()
           
 
Method Summary
static void printHexByte(byte b)
          Print a single byte as a hex pair to System-out.
static void printHexLine(byte[] buf, int address, int count)
          Dump one line of memory as hex dump.
static void printHexRange(byte[] buf, int addressBegin, int addressEnd)
          Dump a range of memory in hex dump format.
static void printHexWord(int word)
          Print a single word as a hex quad to System-out.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Hexadecimal

public Hexadecimal()
Method Detail

printHexRange

public static void printHexRange(byte[] buf,
                                 int addressBegin,
                                 int addressEnd)
Dump a range of memory in hex dump format.

Note that addressBegin will appear flush left, instead of being properly aligned to a 16-byte boundary. It would be a good enhancement, I think, to start printing at the correct column position. For example, dumping from address 0x0003 will currently print:

 0003: 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00 ........ ........
 
whereas it should print:
 0003:          00 00 00 00 00  00 00 00 00 00 00 00 00 ........ ........
 

Parameters:
buf - The byte array to interpret data from.
addressBegin - The starting address in buf to dump data from.
addressEnd - The ending address.

printHexLine

public static void printHexLine(byte[] buf,
                                int address,
                                int count)
Dump one line of memory as hex dump.

This will dump the 16 bytes or less given in the following format:

 aaaa: hh hh hh hh hh hh hh hh  hh hh hh hh hh hh hh hh  ........ ........
 


printHexByte

public static void printHexByte(byte b)
Print a single byte as a hex pair to System-out.

Parameters:
b - The byte to print.

printHexWord

public static void printHexWord(int word)
Print a single word as a hex quad to System-out.

Parameters:
word - The 2-byte value to print.


Copyright ? 2002 Clarity Systems Group, LLC. All Rights Reserved.