Package com.pixelmed.utils

# Class HexDump

java.lang.Object
com.pixelmed.utils.HexDump

public class HexDump extends Object

Various static methods helpful for dumping decimal and hexadecimal values.

## Method Summary

Modifier and Type
Method
Description
`static String`
`byteArrayToHexString(byte[] b)`
Create a continuous hex string representation of a byte array.
`static String`
`byteArrayToHexString(byte[] b, int offset, int length)`
Create a continuous hex string representation of a specified portion of a byte array.
`static String`
`byteArrayToPrintableString(byte[] b)`
Create a printable string representation of a specified portion of a byte array in the default character set.
`static String`
`byteArrayToPrintableString(byte[] b, int offset, int length)`
Create a printable string representation of a specified portion of a byte array in the default character set.
`static String`
`byteToPaddedDecimalString(int i)`
Convert an unsigned byte value to a decimal string of three characters with leading space padding.
`static String`
`byteToPaddedHexString(int i)`
Convert an unsigned byte value to a hexadecimal string of two characters with leading zero padding.
`static String`
`byteToPaddedHexStringWith0x(int i)`
Convert an unsigned byte value to a hexadecimal string of two characters with leading 0x and leading zero padding.
`static String`
`dump(byte[] b)`
Create a dump of the decimal offset, hexadecimal values and printable string values of a byte array.
`static String`
`dump(byte[] b, int lng)`
Create a dump of the decimal offset, hexadecimal values and printable string values of a byte array.
`static String`
`dump(byte[] b, int offset, int lng)`
Create a dump of the decimal offset, hexadecimal values and printable string values of a byte array.
`static String`
`dump(String s)`
Create a dump of the decimal offset, hexadecimal values of the Unicode code points and printable string values of a String.
`static String`
`dump(String s, int lng)`
Create a dump of the decimal offset, hexadecimal values of the Unicode code points and printable string values of a String.
`static String`
`dump(String s, int offset, int lng)`
Create a dump of the decimal offset, hexadecimal values of the Unicode code points and printable string values of a String.
`static String`
`intToPaddedDecimalString(int i)`
Convert an integer value to a decimal string of nine characters with leading space padding.
`static String`
`intToPaddedHexString(int i)`
Convert an integer value to a hexadecimal string of eight characters with leading zero padding.
`static String`
`intToPaddedHexStringWith0x(int i)`
Convert an integer value to a hexadecimal string of eight characters with leading 0x and leading zero padding.
`static boolean`
`isPrintableCharacter(char c)`
Test whether or not a character in the default character set is printable.
`static void`
`main(String[] arg)`
Unit test.
`static String`
`shortToPaddedDecimalString(int i)`
Convert an unsigned short value to a decimal string of six characters with leading space padding.
`static String`
`shortToPaddedHexString(int i)`
Convert an unsigned short value to a hexadecimal string of four characters with leading zero padding.
`static String`
`shortToPaddedHexStringWith0x(int i)`
Convert an unsigned short value to a hexadecimal string of four characters with leading 0x and leading zero padding.
`static String`
`toPaddedDecimalString(int i, char pad, int length, String prefix, String suffix)`
Convert an integer value to a decimal string, padding it to a specified length, and prepending a prefix and appending a suffix.
`static String`
`toPaddedHexString(int i, char pad, int length, String prefix, String suffix)`
Convert an integer value to a hexadecimal string, padding it to a specified length, and prepending a prefix and appending a suffix.

### Methods inherited from class java.lang.Object

`clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### toPaddedDecimalString

public static String toPaddedDecimalString(int i, char pad, int length, String prefix, String suffix)

Convert an integer value to a decimal string, padding it to a specified length, and prepending a prefix and appending a suffix.

Parameters:
  `i` - the integer to dump
  `pad` - the pad character to append before the string value of the integer if necessary
  `length` - the desired length of string converted integer and padding (not including the prefix or suffix)
  `prefix` - the string to prepend
  `suffix` - the string to append
Returns:
  the prefix, padded decimal string and suffix

### byteToPaddedDecimalString

public static String byteToPaddedDecimalString(int i)

Convert an unsigned byte value to a decimal string of three characters with leading space padding.

Parameters:
  `i` - the unsigned byte value
Returns:
  the padded decimal string

### shortToPaddedDecimalString

public static String shortToPaddedDecimalString(int i)

Convert an unsigned short value to a decimal string of six characters with leading space padding.

Parameters:
  `i` - the unsigned short value
Returns:
  the padded decimal string

### intToPaddedDecimalString

public static String intToPaddedDecimalString(int i)

Convert an integer value to a decimal string of nine characters with leading space padding.

Parameters:
  `i` - the integer value
Returns:
  the padded decimal string

### toPaddedHexString

public static String toPaddedHexString(int i, char pad, int length, String prefix, String suffix)

Convert an integer value to a hexadecimal string, padding it to a specified length, and prepending a prefix and appending a suffix.

Parameters:
  `i` - the integer to dump
  `pad` - the pad character to append before the string value of the integer if necessary
  `length` - the desired length of string converted integer and padding (not including the prefix or suffix)
  `prefix` - the string to prepend
  `suffix` - the string to append
Returns:
  the prefix, padded hexadecimal string and suffix

### byteToPaddedHexString

public static String byteToPaddedHexString(int i)

Convert an unsigned byte value to a hexadecimal string of two characters with leading zero padding.

Parameters:
  `i` - the unsigned byte value
Returns:
  the padded hexadecimal string

### shortToPaddedHexString

public static String shortToPaddedHexString(int i)

Convert an unsigned short value to a hexadecimal string of four characters with leading zero padding.

Parameters:
  `i` - the unsigned short value
Returns:
  the padded decimal string

### intToPaddedHexString

public static String intToPaddedHexString(int i)

Convert an integer value to a hexadecimal string of eight characters with leading zero padding.

Parameters:
  `i` - the integer value
Returns:
  the padded decimal string

### byteToPaddedHexStringWith0x

public static String byteToPaddedHexStringWith0x(int i)

Convert an unsigned byte value to a hexadecimal string of two characters with leading 0x and leading zero padding.

Parameters:
  `i` - the unsigned byte value
Returns:
  the padded hexadecimal string

### shortToPaddedHexStringWith0x

public static String shortToPaddedHexStringWith0x(int i)

Convert an unsigned short value to a hexadecimal string of four characters with leading 0x and leading zero padding.

Parameters:
  `i` - the unsigned short value
Returns:
  the padded decimal string

### intToPaddedHexStringWith0x

public static String intToPaddedHexStringWith0x(int i)

Convert an integer value to a hexadecimal string of eight characters with leading 0x and leading zero padding.

Parameters:
  `i` - the integer value
Returns:
  the padded decimal string

### isPrintableCharacter

public static boolean isPrintableCharacter(char c)

Test whether or not a character in the default character set is printable.

Parameters:
  `c` - character to test
Returns:
  true if character is printable

### byteArrayToPrintableString

public static String byteArrayToPrintableString(byte[] b, int offset, int length)

Create a printable string representation of a specified portion of a byte array in the default character set.

Unprintable characters are represented by a period ('.') character.

Parameters:
  `b` - the byte array
  `offset` - the start of the bytes to be extracted
  `length` - the number of bytes to be extracted
Returns:
  a string of the specified length containing the printable characters of the supplied bytes

### byteArrayToPrintableString

public static String byteArrayToPrintableString(byte[] b)

Create a printable string representation of a specified portion of a byte array in the default character set.

Unprintable characters are represented by a period ('.') character.

Parameters:
  `b` - the byte array
Returns:
  a string containing the printable characters of the supplied bytes

### byteArrayToHexString

public static String byteArrayToHexString(byte[] b, int offset, int length)

Create a continuous hex string representation of a specified portion of a byte array.

Parameters:
  `b` - the byte array
  `offset` - the start of the bytes to be extracted
  `length` - the number of bytes to be extracted
Returns:
  a string containing the hex representation of the supplied bytes

### byteArrayToHexString

public static String byteArrayToHexString(byte[] b)

Create a continuous hex string representation of a byte array.

Parameters:
  `b` - the byte array
Returns:
  a string containing the hex representation of the supplied bytes

### dump

public static String dump(byte[] b, int offset, int lng)

Create a dump of the decimal offset, hexadecimal values and printable string values of a byte array.

The result is similar to a dump produced by the unix od or MacOS X 'hexdump -C' commands.

Parameters:
  `b` - the byte array to be dumped
  `offset` - the offset into the buffer to be dumped
  `lng` - the number of bytes to be dumped
Returns:
  a string containing the multiline result

### dump

public static String dump(byte[] b, int lng)

Create a dump of the decimal offset, hexadecimal values and printable string values of a byte array.

The result is similar to a dump produced by the unix od or MacOS X 'hexdump -C' commands.

Parameters:
  `b` - the byte array to be dumped
  `lng` - the number of bytes to be dumped
Returns:
  a string containing the multiline result

### dump

public static String dump(byte[] b)

Create a dump of the decimal offset, hexadecimal values and printable string values of a byte array.

The result is similar to a dump produced by the unix od or MacOS X 'hexdump -C' commands.

Parameters:
  `b` - the byte array to be dumped in its entirety
Returns:
  a string containing the multiline result

### dump

public static String dump(String s, int offset, int lng)

Create a dump of the decimal offset, hexadecimal values of the Unicode code points and printable string values of a String.

Parameters:
  `s` - the String to be dumped
  `offset` - the offset into the String to be dumped
  `lng` - the number of characters to be dumped
Returns:
  a string containing the multiline result

### dump

public static String dump(String s, int lng)

Create a dump of the decimal offset, hexadecimal values of the Unicode code points and printable string values of a String.

Parameters:
  `s` - the String to be dumped
  `lng` - the number of characters to be dumped
Returns:
  a string containing the multiline result

### dump

public static String dump(String s)

Create a dump of the decimal offset, hexadecimal values of the Unicode code points and printable string values of a String.

Parameters:
  `s` - the String to be dumped dumped in its entirety
Returns:
  a string containing the multiline result

### main

public static void main(String[] arg)

Unit test.

Parameters:
  `arg` - ignored