org.red5.io.utils
Class HexDump

java.lang.Object
  extended by org.red5.io.utils.HexDump

public class HexDump
extends Object

Hexadecimal byte dumper

Author:
Niko Schweitzer

Constructor Summary
HexDump()
           
 
Method Summary
static String byteArrayToBinaryString(byte[] block)
          Description of the Method
static String byteArrayToHexString(byte[] block)
          Description of the Method
static String byteArrayToHexString(byte[] block, int offset, int length)
          Description of the Method
static void dumpHex(StringBuilder sb, byte[] b)
          Dumps a byte array as hex.
static String formatHexDump(String in)
           
static byte[] hexStringToByteArray(String strA)
          Converts readable hex-String to byteArray
static void main(String[] args)
          test and demo for the Convert class
static String prettyPrintHex(byte[] baToConvert)
          Method prettyPrintHex
static String prettyPrintHex(ByteBuffer bbToConvert)
          Method prettyPrintHex
static String prettyPrintHex(String sToConvert)
          Method prettyPrintHex
static void setBitDigits(char[] bd)
          Sets the BitDigits attribute of the Convert class
static void setBitDigits(char zeroBit, char oneBit)
          Method setBitDigits
static void setByteSeparator(char bs)
          Sets the ByteSeparator attribute of the Convert class
static void setWithByteSeparator(boolean bs)
          Sets the WithByteSeparator attribute of the Convert class
static String stringToHexString(String in)
          Description of the Method
static String toBinaryString(byte b)
          Method toBinaryString
static String toBinaryString(byte[] ba)
          Method toBinaryString
static String toBinaryString(int i)
          Method toBinaryString
static String toBinaryString(long l)
          Method toBinaryString
static String toBinaryString(short s)
          Method toBinaryString
static byte[] toByteArray(int i)
          Method toByteArray
static byte[] toByteArray(long l)
          Method toByteArray
static byte[] toByteArray(short s)
          Method toByteArray
static String toHexString(byte b)
          Method toHexString
static String toHexString(byte[] ba)
          Returns a string of hexadecimal digits from a byte array.
static String toHexString(byte[] ba, int offset, int length)
          converts String to Hex String.
static String toHexString(int i)
          Method toHexString
static String toHexString(long l)
          Method toHexString
static String toHexString(short s)
          Description of the Method
static String toString(byte b)
          Method toString
static String toString(byte[] ba)
          Method toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HexDump

public HexDump()
Method Detail

prettyPrintHex

public static String prettyPrintHex(ByteBuffer bbToConvert)
Method prettyPrintHex

Parameters:
bbToConvert - ByteBuffer to encode
Returns:
Hexdump string

prettyPrintHex

public static String prettyPrintHex(byte[] baToConvert)
Method prettyPrintHex

Parameters:
baToConvert - Array of bytes to encode
Returns:
Hexdump string

prettyPrintHex

public static String prettyPrintHex(String sToConvert)
Method prettyPrintHex

Parameters:
sToConvert - string to convert
Returns:
hexdump string

dumpHex

public static void dumpHex(StringBuilder sb,
                           byte[] b)
Dumps a byte array as hex.

Parameters:
sb -
b -

setWithByteSeparator

public static void setWithByteSeparator(boolean bs)
Sets the WithByteSeparator attribute of the Convert class

Parameters:
bs - The new WithByteSeparator value

setByteSeparator

public static void setByteSeparator(char bs)
Sets the ByteSeparator attribute of the Convert class

Parameters:
bs - The new ByteSeparator value

setBitDigits

public static void setBitDigits(char[] bd)
                         throws Exception
Sets the BitDigits attribute of the Convert class

Parameters:
bd - The new BitDigits value
Throws:
Exception - Description of Exception

setBitDigits

public static void setBitDigits(char zeroBit,
                                char oneBit)
Method setBitDigits

Parameters:
zeroBit - zero bit
oneBit - one bit param redFish red fish param blueFish blue fish

byteArrayToBinaryString

public static String byteArrayToBinaryString(byte[] block)
Description of the Method

Parameters:
block - Description of Parameter
Returns:
Description of the Returned Value

toBinaryString

public static String toBinaryString(byte[] ba)
Method toBinaryString

Parameters:
ba - binary array
Returns:
the binary representation of the byte array

toBinaryString

public static String toBinaryString(byte b)
Method toBinaryString

Parameters:
b - byte array
Returns:
the binary representation of the byte

toBinaryString

public static String toBinaryString(short s)
Method toBinaryString

Parameters:
s - short
Returns:
the binary representation of the short

toBinaryString

public static String toBinaryString(int i)
Method toBinaryString

Parameters:
i - integer
Returns:
the binary representation of the int

toBinaryString

public static String toBinaryString(long l)
Method toBinaryString

Parameters:
l - long
Returns:
the binary representation of the long

toByteArray

public static final byte[] toByteArray(short s)
Method toByteArray

Parameters:
s - short
Returns:
the short as array of bytes

toByteArray

public static final byte[] toByteArray(int i)
Method toByteArray

Parameters:
i - int
Returns:
the int as array of bytes

toByteArray

public static final byte[] toByteArray(long l)
Method toByteArray

Parameters:
l - long
Returns:
the long as array of bytes

byteArrayToHexString

public static String byteArrayToHexString(byte[] block)
Description of the Method

Parameters:
block - Description of Parameter
Returns:
Description of the Returned Value

stringToHexString

public static String stringToHexString(String in)
Description of the Method

Parameters:
in - string to be converted
Returns:
String in readable hex encoding

byteArrayToHexString

public static String byteArrayToHexString(byte[] block,
                                          int offset,
                                          int length)
Description of the Method

Parameters:
block - Description of Parameter
offset - Description of Parameter
length - Description of Parameter
Returns:
Description of the Returned Value

toHexString

public static String toHexString(byte[] ba)
Returns a string of hexadecimal digits from a byte array. Each byte is converted to 2 hex symbols.

Parameters:
ba - Description of Parameter
Returns:
Description of the Returned Value

toHexString

public static String toHexString(byte b)
Method toHexString

Parameters:
b - byte
Returns:
the hexadecimal representation of the byte

toHexString

public static String toHexString(short s)
Description of the Method

Parameters:
s - short
Returns:
Description of the Returned Value

toHexString

public static String toHexString(int i)
Method toHexString

Parameters:
i - int
Returns:
the hexadecimal representation of the int

toHexString

public static String toHexString(long l)
Method toHexString

Parameters:
l - long
Returns:
the hexadecimal representation of the long

toString

public static String toString(byte[] ba)
Method toString

Parameters:
ba - byte array
Returns:
the byte array as string

toString

public static String toString(byte b)
Method toString

Parameters:
b - byte
Returns:
the byte as string

toHexString

public static String toHexString(byte[] ba,
                                 int offset,
                                 int length)
converts String to Hex String. Example: niko ->6E696B6F

Parameters:
ba - byte array
offset - offset in array
length - number of bytes
Returns:
Description of the Returned Value

hexStringToByteArray

public static byte[] hexStringToByteArray(String strA)
Converts readable hex-String to byteArray

Parameters:
strA - string
Returns:
the hexadecimal string as byte array

main

public static void main(String[] args)
test and demo for the Convert class

Parameters:
args - none needed

formatHexDump

public static String formatHexDump(String in)


Copyright © 2006-2012 The Red5 Project