Package fr.dyade.aaa.common
Class BinaryDump
- java.lang.Object
-
- fr.dyade.aaa.common.BinaryDump
-
public final class BinaryDump extends Object
This class allows to produce various dump of bytes arrays.
-
-
Constructor Summary
Constructors Constructor Description BinaryDump()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static Stringdump(byte value)static Stringdump(byte[] data, long offset, int index)dump an array of bytes to a Stringprivate static Stringdump(long value)static StringtoHex(byte value)Converts the parameter to a hex value.static StringtoHex(byte[] value)Dumps the byte array in hexadecimal format.static StringtoHex(byte[] value, int bytesPerLine)Converts the parameter to a hex value breaking the results into lines.static StringtoHex(byte[] value, int offset, int length)dump a part of the array of bytes to a Stringprivate static StringtoHex(long value, int digits)static StringtoJSon(byte[] data)static StringtoJSon(byte[] data, int offset, int length)static voidtoJSon(Appendable appendable, byte[] data)static voidtoJSon(Appendable appendable, byte[] data, int offset, int length)static voidtoJSon(StringBuilder strbuf, byte[] data)static voidtoJSon(StringBuilder strbuf, byte[] data, int offset, int length)
-
-
-
Field Detail
-
EOL
public static final String EOL
-
_hexcodes
private static final char[] _hexcodes
-
_shifts
private static final int[] _shifts
-
-
Method Detail
-
dump
public static String dump(byte[] data, long offset, int index)
dump an array of bytes to a String- Parameters:
data- the byte array to be dumpedoffset- its offset, whatever that might meanindex- initial index into the byte array- Returns:
- output string
- Throws:
ArrayIndexOutOfBoundsException- if the index is outside the data array's bounds
-
dump
private static String dump(long value)
-
dump
private static String dump(byte value)
-
toJSon
public static String toJSon(byte[] data)
-
toJSon
public static String toJSon(byte[] data, int offset, int length)
-
toJSon
public static void toJSon(StringBuilder strbuf, byte[] data)
-
toJSon
public static void toJSon(StringBuilder strbuf, byte[] data, int offset, int length)
-
toJSon
public static void toJSon(Appendable appendable, byte[] data) throws IOException
- Throws:
IOException
-
toJSon
public static void toJSon(Appendable appendable, byte[] data, int offset, int length) throws IOException
- Throws:
IOException
-
toHex
public static String toHex(byte[] value)
Dumps the byte array in hexadecimal format.- Parameters:
value- The value to convert- Returns:
- A String representing the array of bytes
-
toHex
public static String toHex(byte[] value, int offset, int length)
dump a part of the array of bytes to a String- Parameters:
value- the byte array to be dumpedoffset- starting index into the byte arraylength- length of the byte array to dump.- Returns:
- output string
-
toHex
public static String toHex(byte[] value, int bytesPerLine)
Converts the parameter to a hex value breaking the results into lines.- Parameters:
value- The value to convertbytesPerLine- The maximum number of bytes per line. The next byte will be written to a new line- Returns:
- A String representing the array of bytes
-
toHex
public static String toHex(byte value)
Converts the parameter to a hex value.- Parameters:
value- The value to convert- Returns:
- The result right padded with 0
-
toHex
private static String toHex(long value, int digits)
-
-