Package org.jf.util
Class Hex
java.lang.Object
org.jf.util.Hex
Utilities for formatting numbers as hexadecimal.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringdump(byte[] arr, int offset, int length, int outOffset, int bpl, int addressLength) Formats a hex dump of a portion of abyte[].static Strings1(int v) Formats anintas a 1-byte signed hex value.static Strings2(int v) Formats anintas a 2-byte signed hex value.static Strings4(int v) Formats anintas a 4-byte signed hex value.static Strings8(long v) Formats alongas an 8-byte signed hex value.static Stringu1(int v) Formats anintas a 1-byte unsigned hex value.static Stringu2(int v) Formats anintas a 2-byte unsigned hex value.static Stringu2or4(int v) Formats anintas either a 2-byte unsigned hex value (if the value is small enough) or a 4-byte unsigned hex value (if not).static Stringu3(int v) Formats anintas a 3-byte unsigned hex value.static Stringu4(int v) Formats anintas a 4-byte unsigned hex value.static Stringu8(long v) Formats alongas an 8-byte unsigned hex value.static StringuNibble(int v) Formats anintas a 4-bit unsigned hex nibble.
-
Constructor Details
-
Hex
private Hex()This class is uninstantiable.
-
-
Method Details
-
u8
Formats alongas an 8-byte unsigned hex value.- Parameters:
v- value to format- Returns:
- non-null; formatted form
-
u4
Formats anintas a 4-byte unsigned hex value.- Parameters:
v- value to format- Returns:
- non-null; formatted form
-
u3
Formats anintas a 3-byte unsigned hex value.- Parameters:
v- value to format- Returns:
- non-null; formatted form
-
u2
Formats anintas a 2-byte unsigned hex value.- Parameters:
v- value to format- Returns:
- non-null; formatted form
-
u2or4
Formats anintas either a 2-byte unsigned hex value (if the value is small enough) or a 4-byte unsigned hex value (if not).- Parameters:
v- value to format- Returns:
- non-null; formatted form
-
u1
Formats anintas a 1-byte unsigned hex value.- Parameters:
v- value to format- Returns:
- non-null; formatted form
-
uNibble
Formats anintas a 4-bit unsigned hex nibble.- Parameters:
v- value to format- Returns:
- non-null; formatted form
-
s8
Formats alongas an 8-byte signed hex value.- Parameters:
v- value to format- Returns:
- non-null; formatted form
-
s4
Formats anintas a 4-byte signed hex value.- Parameters:
v- value to format- Returns:
- non-null; formatted form
-
s2
Formats anintas a 2-byte signed hex value.- Parameters:
v- value to format- Returns:
- non-null; formatted form
-
s1
Formats anintas a 1-byte signed hex value.- Parameters:
v- value to format- Returns:
- non-null; formatted form
-
dump
public static String dump(byte[] arr, int offset, int length, int outOffset, int bpl, int addressLength) Formats a hex dump of a portion of abyte[]. The result is always newline-terminated, unless the passed-in length was zero, in which case the result is always the empty string ("").- Parameters:
arr- non-null; array to formatoffset- >= 0; offset to the part to dumplength- >= 0; number of bytes to dumpoutOffset- >= 0; first output offset to printbpl- >= 0; number of bytes of output per lineaddressLength- {2,4,6,8}; number of characters for each address header- Returns:
- non-null; a string of the dump
-