Package org.red5.io.utils
Class HexDump
java.lang.Object
org.red5.io.utils.HexDump
Hexadecimal byte dumper
- Author:
- Niko Schweitzer
-
Field Summary
Modifier and TypeFieldDescriptionprivate static char[]
Field BIT_DIGITprivate static char
Field BYTE_SEPARATORprivate static final byte[]
Field COMPARE_BITSprivate static final char[]
Field HEX_DIGITSprivate static boolean
Field WITH_BYTE_SEPARATOR -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate static void
byte2bin
(byte b, StringBuffer buf) Description of the Methodprivate static void
byte2hex
(byte b, StringBuffer buf) Description of the Methodstatic String
byteArrayToBinaryString
(byte[] block) Description of the Methodstatic String
byteArrayToHexString
(byte[] block) Description of the Methodstatic String
byteArrayToHexString
(byte[] block, int offset, int length) Description of the Methodstatic 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 byteArrayprivate static String
intToHexString
(int n) Returns a string of 8 hexadecimal digits (most significant digit first) corresponding to the integer n , which is treated as unsigned.static String
prettyPrintHex
(byte[] baToConvert) Method prettyPrintHexstatic String
prettyPrintHex
(String sToConvert) Method prettyPrintHexstatic String
prettyPrintHex
(ByteBuffer bbToConvert) Method prettyPrintHexstatic void
setBitDigits
(char[] bd) Sets the BitDigits attribute of the Convert classstatic void
setBitDigits
(char zeroBit, char oneBit) Method setBitDigitsstatic void
setByteSeparator
(char bs) Sets the ByteSeparator attribute of the Convert classstatic void
setWithByteSeparator
(boolean bs) Sets the WithByteSeparator attribute of the Convert classstatic String
Description of the Methodstatic String
toBinaryString
(byte b) Method toBinaryStringstatic String
toBinaryString
(byte[] ba) Method toBinaryStringstatic String
toBinaryString
(int i) Method toBinaryStringstatic String
toBinaryString
(long l) Method toBinaryStringstatic String
toBinaryString
(short s) Method toBinaryStringstatic final byte[]
toByteArray
(int i) Method toByteArraystatic final byte[]
toByteArray
(long l) Method toByteArraystatic final byte[]
toByteArray
(short s) Method toByteArraystatic String
toHexString
(byte b) Method toHexStringstatic 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 toHexStringstatic String
toHexString
(long l) Method toHexStringstatic String
toHexString
(short s) Description of the Methodstatic String
toString
(byte b) Method toStringstatic String
toString
(byte[] ba) Method toString
-
Field Details
-
HEX_DIGITS
private static final char[] HEX_DIGITSField HEX_DIGITS -
BIT_DIGIT
private static char[] BIT_DIGITField BIT_DIGIT -
COMPARE_BITS
private static final byte[] COMPARE_BITSField COMPARE_BITS -
BYTE_SEPARATOR
private static char BYTE_SEPARATORField BYTE_SEPARATOR -
WITH_BYTE_SEPARATOR
private static boolean WITH_BYTE_SEPARATORField WITH_BYTE_SEPARATOR
-
-
Constructor Details
-
HexDump
public HexDump()
-
-
Method Details
-
prettyPrintHex
Method prettyPrintHex- Parameters:
bbToConvert
- ByteBuffer to encode- Returns:
- Hexdump string
-
prettyPrintHex
Method prettyPrintHex- Parameters:
baToConvert
- Array of bytes to encode- Returns:
- Hexdump string
-
prettyPrintHex
Method prettyPrintHex- Parameters:
sToConvert
- string to convert- Returns:
- hexdump string
-
dumpHex
Dumps a byte array as hex.- Parameters:
sb
- string builderb
- bytes
-
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
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 bitoneBit
- one bit param redFish red fish param blueFish blue fish
-
byteArrayToBinaryString
Description of the Method- Parameters:
block
- Description of Parameter- Returns:
- Description of the Returned Value
-
toBinaryString
Method toBinaryString- Parameters:
ba
- binary array- Returns:
- the binary representation of the byte array
-
toBinaryString
Method toBinaryString- Parameters:
b
- byte array- Returns:
- the binary representation of the byte
-
toBinaryString
Method toBinaryString- Parameters:
s
- short- Returns:
- the binary representation of the short
-
toBinaryString
Method toBinaryString- Parameters:
i
- integer- Returns:
- the binary representation of the int
-
toBinaryString
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
Description of the Method- Parameters:
block
- Description of Parameter- Returns:
- Description of the Returned Value
-
stringToHexString
Description of the Method- Parameters:
in
- string to be converted- Returns:
- String in readable hex encoding
-
byteArrayToHexString
Description of the Method- Parameters:
block
- Description of Parameteroffset
- Description of Parameterlength
- Description of Parameter- Returns:
- Description of the Returned Value
-
toHexString
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
Method toHexString- Parameters:
b
- byte- Returns:
- the hexadecimal representation of the byte
-
toHexString
Description of the Method- Parameters:
s
- short- Returns:
- Description of the Returned Value
-
toHexString
Method toHexString- Parameters:
i
- int- Returns:
- the hexadecimal representation of the int
-
toHexString
Method toHexString- Parameters:
l
- long- Returns:
- the hexadecimal representation of the long
-
toString
Method toString- Parameters:
ba
- byte array- Returns:
- the byte array as string
-
toString
Method toString- Parameters:
b
- byte- Returns:
- the byte as string
-
toHexString
converts String to Hex String. Example: niko == 6E696B6F- Parameters:
ba
- byte arrayoffset
- offset in arraylength
- number of bytes- Returns:
- Description of the Returned Value
-
hexStringToByteArray
Converts readable hex-String to byteArray- Parameters:
strA
- string- Returns:
- the hexadecimal string as byte array
-
byte2hex
Description of the Method- Parameters:
b
- Description of Parameterbuf
- Description of Parameter
-
byte2bin
Description of the Method- Parameters:
b
- Description of Parameterbuf
- Description of Parameter
-
intToHexString
Returns a string of 8 hexadecimal digits (most significant digit first) corresponding to the integer n , which is treated as unsigned.- Parameters:
n
- Description of Parameter- Returns:
- Description of the Returned Value
-
formatHexDump
-