java.lang.Object | |
↳ | com.pnfsoftware.jeb.util.format.Formatter |
A collection of binary (and number) formatting and escaping methods.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Formatter() |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
static String | byteArrayToHexString(byte[] data, int pos) | ||||||||||
static String | byteArrayToHexString(byte[] data) | ||||||||||
static String | byteArrayToHexString(byte[] data, int pos, int end) | ||||||||||
static String | escapeByte(int v) | ||||||||||
static String | escapeBytes(byte[] bytes, int offset, int size) | ||||||||||
static String | escapeBytes(byte[] bytes) | ||||||||||
static String |
escapeCharacter(char c, boolean keepUnicodePrintables)
Escape a character, if necessary.
| ||||||||||
static String |
escapeCharacter(char c)
Escape a string, keeping unicode printable characters.
| ||||||||||
static String |
escapeString(String s, boolean keepUnicodePrintables, Set<Character> doNotEscapeList)
Escape a string.
| ||||||||||
static String |
escapeString(String s, boolean keepUnicodePrintables)
Escape a string.
| ||||||||||
static String | escapeString(CharSequence s) | ||||||||||
static String | escapeToJavaStringArray(Collection<? extends Object> objects) | ||||||||||
static String |
formatBinaryBlock(byte[] data, int offset, int size, long offsetDelta, boolean is64bit)
Format a block of bytes as a buffer of hexadecimal lines.
| ||||||||||
static String |
formatBinaryBlock(byte[] data)
Format a block of bytes.
| ||||||||||
static String |
formatBinaryBlock(byte[] data, int offset, int size, int offsetDelta)
Format a block of bytes.
| ||||||||||
static String |
formatBinaryBlock(byte[] data, int offset, int size)
Format a block of bytes.
| ||||||||||
static String |
formatBinaryLine(byte[] data)
Format a block of bytes.
| ||||||||||
static String |
formatBinaryLine(byte[] data, int offset, int size)
Format a block of bytes.
| ||||||||||
static String |
formatBinaryLine(byte[] data, int offset, int size, int minVirtualSize)
Format a block of bytes as a hexadecimal string representation.
| ||||||||||
static String | formatBinaryLineTruncate(byte[] data, int offset, int size, int fixedCount) | ||||||||||
static String | formatBinaryLineTruncate(byte[] data, int offset, int size, int maxSize, char truncateChar) | ||||||||||
static String | formatHexNumbers(List<? extends Number> list) | ||||||||||
static String | formatNumbers(List<? extends Number> list, int base, String pfx, String sfx) | ||||||||||
static byte[] |
hexStringToByteArray(String s)
Convert a series of hexadecimal String to a byte array.
| ||||||||||
static byte[] |
hexStringToByteArray(String s, int pos, int end)
Convert a series of hexadecimal String to a byte array.
| ||||||||||
static boolean |
isPrintableChar(char c)
Determine if a character is printable.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Escape a character, if necessary.
c | the character to be escaped |
---|---|
keepUnicodePrintables | if true, a printable unicode, non-ascii character will be left unescaped |
Escape a string, keeping unicode printable characters.
Escape a string. See escapeCharacter(char, boolean)
.
s | the string to be escapes |
---|---|
keepUnicodePrintables | keep or escape non-ansi printable unicode chars (eg, KCJ/Russian/etc. sets) |
doNotEscapeList | optional - those characters won't be escaped (careful!) |
Escape a string.
Format a block of bytes as a buffer of hexadecimal lines. Each line represents the 16 bytes of buffer data; it is prefixed by an optional offset (address) base and suffixed by the Ascii representation of the bytes. Note that non-printable, non-Ascii characters are represented as dots.
data | bytes buffer |
---|---|
offset | beginning of bytes sequence to be formatted |
size | number of bytes to be formatted |
offsetDelta | an offset delta |
is64bit | indicates if the prefix offset should be formatted as a 64-bit or 32-bit value |
Format a block of bytes. Same as formatBinaryBlock(data, 0, data.length)
data | bytes buffer |
---|
Format a block of bytes. Same as formatBinaryBlock(data, offset, size, offsetDelta, false)
Format a block of bytes. Same as formatBinaryBlock(data, offset, size, 0)
data | bytes buffer |
---|---|
offset | beginning of bytes sequence to be formatted |
size | number of bytes to be formatted |
Format a block of bytes. Same as formatBinaryLine(data, 0, data.length, 0)
.
data | bytes buffer |
---|
Format a block of bytes. Same as formatBinaryLine(data, 0, size, size)
.
Format a block of bytes as a hexadecimal string representation. Bytes will be represented space-separated.
data | bytes buffer |
---|---|
offset | beginning of bytes sequence to be formatted |
size | number of bytes to be formatted |
minVirtualSize | minimum number of bytes that the resulting string is supposed to represent; phantom bytes (formatted as empty space) will be appended if necessary |
Convert a series of hexadecimal String to a byte array. Remove potential "h" suffix and "0x" prefix.
s | Input String |
---|
Convert a series of hexadecimal String to a byte array. Input must be padded with zeroes. If data is invalid, a null array is returned.
hexStringToByteArray("1234ABCD", 0, 8) => {0x12, 0x23, 0xAB, 0xCD} hexStringToByteArray("1234ABCD", 0, 4) => {0x12, 0x23} hexStringToByteArray("1234ABCD", 0, 5) => null
s | Input String |
---|---|
pos | the start parsing position |
end | the end parsing position |
Determine if a character is printable. This method defines a character as `printable`
IFF:
- it is not an ISO control character
- it is not a surrogate pair (low or high)
- it is not considered a special Unicode character
c | the input character |
---|