Package org.red5.io.utils
Class HexDump
java.lang.Object
org.red5.io.utils.HexDump
Hexadecimal byte dumper
- Author:
- Niko Schweitzer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static char[]Field BIT_DIGITprivate static charField BYTE_SEPARATORprivate static final byte[]Field COMPARE_BITSprivate static final char[]Field HEX_DIGITSprivate static booleanField WITH_BYTE_SEPARATOR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidbyte2bin(byte b, StringBuffer buf) Description of the Methodprivate static voidbyte2hex(byte b, StringBuffer buf) Description of the Methodstatic StringbyteArrayToBinaryString(byte[] block) Description of the Methodstatic StringbyteArrayToHexString(byte[] block) Description of the Methodstatic StringbyteArrayToHexString(byte[] block, int offset, int length) Description of the Methodstatic voiddumpHex(StringBuilder sb, byte[] b) Dumps a byte array as hex.static StringformatHexDump(String in) static byte[]hexStringToByteArray(String strA) Converts readable hex-String to byteArrayprivate static StringintToHexString(int n) Returns a string of 8 hexadecimal digits (most significant digit first) corresponding to the integer n , which is treated as unsigned.static StringprettyPrintHex(byte[] baToConvert) Method prettyPrintHexstatic StringprettyPrintHex(String sToConvert) Method prettyPrintHexstatic StringprettyPrintHex(ByteBuffer bbToConvert) Method prettyPrintHexstatic voidsetBitDigits(char[] bd) Sets the BitDigits attribute of the Convert classstatic voidsetBitDigits(char zeroBit, char oneBit) Method setBitDigitsstatic voidsetByteSeparator(char bs) Sets the ByteSeparator attribute of the Convert classstatic voidsetWithByteSeparator(boolean bs) Sets the WithByteSeparator attribute of the Convert classstatic StringDescription of the Methodstatic StringtoBinaryString(byte b) Method toBinaryStringstatic StringtoBinaryString(byte[] ba) Method toBinaryStringstatic StringtoBinaryString(int i) Method toBinaryStringstatic StringtoBinaryString(long l) Method toBinaryStringstatic StringtoBinaryString(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 StringtoHexString(byte b) Method toHexStringstatic StringtoHexString(byte[] ba) Returns a string of hexadecimal digits from a byte array.static StringtoHexString(byte[] ba, int offset, int length) converts String to Hex String.static StringtoHexString(int i) Method toHexStringstatic StringtoHexString(long l) Method toHexStringstatic StringtoHexString(short s) Description of the Methodstatic StringtoString(byte b) Method toStringstatic StringtoString(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
-