@Test public void testAsciiFormat() { final ByteFormat format = ByteFormat.INDIVIDUALLY_AS_ASCII; final byte[] input = new byte[]{-1, 0, 1, 65, 97, 127}; final String expected = "[\uFFFF, \u0000, \u0001, A, a, \u007F]"; assertEquals(expected, cut.formatArray(format, input)); }
@NonNull public String formatArray(@NonNull final ByteFormat format, @Nullable final byte[] array) { if (array == null) { return "null"; } switch (format) { case INDIVIDUALLY_AS_ASCII: return formatAscii(array); case INDIVIDUALLY_AS_ASCII_WITH_UNICODE_SYMBOLS: return formatAsciiWithUnicode(array); case INDIVIDUALLY_AS_UNSIGNED_BYTE: return formatUnsignedByte(array); case INDIVIDUALLY_AS_SIGNED_BYTE: return formatSignedByte(array); default: throw new IllegalArgumentException("Unknown format: " + format); } }
ByteFormatter { @NonNull public String formatArray(@NonNull final ByteFormat format, @Nullable final byte[] array) { if (array == null) { return "null"; } switch (format) { case INDIVIDUALLY_AS_ASCII: return formatAscii(array); case INDIVIDUALLY_AS_ASCII_WITH_UNICODE_SYMBOLS: return formatAsciiWithUnicode(array); case INDIVIDUALLY_AS_UNSIGNED_BYTE: return formatUnsignedByte(array); case INDIVIDUALLY_AS_SIGNED_BYTE: return formatSignedByte(array); default: throw new IllegalArgumentException("Unknown format: " + format); } } }
ByteFormatter { @NonNull public String formatArray(@NonNull final ByteFormat format, @Nullable final byte[] array) { if (array == null) { return "null"; } switch (format) { case INDIVIDUALLY_AS_ASCII: return formatAscii(array); case INDIVIDUALLY_AS_ASCII_WITH_UNICODE_SYMBOLS: return formatAsciiWithUnicode(array); case INDIVIDUALLY_AS_UNSIGNED_BYTE: return formatUnsignedByte(array); case INDIVIDUALLY_AS_SIGNED_BYTE: return formatSignedByte(array); default: throw new IllegalArgumentException("Unknown format: " + format); } } ByteFormatter(); }
ByteFormatter { @NonNull public String formatArray(@NonNull final ByteFormat format, @Nullable final byte[] array) { if (array == null) { return "null"; } switch (format) { case INDIVIDUALLY_AS_ASCII: return formatAscii(array); case INDIVIDUALLY_AS_ASCII_WITH_UNICODE_SYMBOLS: return formatAsciiWithUnicode(array); case INDIVIDUALLY_AS_UNSIGNED_BYTE: return formatUnsignedByte(array); case INDIVIDUALLY_AS_SIGNED_BYTE: return formatSignedByte(array); default: throw new IllegalArgumentException("Unknown format: " + format); } } ByteFormatter(); @NonNull String formatArray(@NonNull final ByteFormat format,
                              @Nullable final byte[] array); }
ByteFormatter { @NonNull public String formatArray(@NonNull final ByteFormat format, @Nullable final byte[] array) { if (array == null) { return "null"; } switch (format) { case INDIVIDUALLY_AS_ASCII: return formatAscii(array); case INDIVIDUALLY_AS_ASCII_WITH_UNICODE_SYMBOLS: return formatAsciiWithUnicode(array); case INDIVIDUALLY_AS_UNSIGNED_BYTE: return formatUnsignedByte(array); case INDIVIDUALLY_AS_SIGNED_BYTE: return formatSignedByte(array); default: throw new IllegalArgumentException("Unknown format: " + format); } } ByteFormatter(); @NonNull String formatArray(@NonNull final ByteFormat format,
                              @Nullable final byte[] array);  }