JSONCodeTableWriter implements VCDiffCodeTableWriter<Appendable> { public void add(final byte[] data, final int offset, final int length) { if (offset < 0 || offset + length > data.length) { throw new IllegalArgumentException(); } if (opcodeAdded) { output.append(','); } output.append('"'); for (int i = offset; i < offset + length; i++) { JSONEscape(data[i], output); } output.append('"'); opcodeAdded = true; } JSONCodeTableWriter(); void init(int dictionarySize); void add(final byte[] data, final int offset, final int length); void addChecksum(int checksum); void copy(int offset, int size); void finishEncoding(Appendable out); void output(Appendable out); void run(int size, byte b); @SuppressWarnings("deprecation") void writeHeader(Appendable out, EnumSet<VCDiffFormatExtension> formatExtensions);  }
@Test public void Add() throws IOException { coder_.add("123".getBytes(StandardCharsets.US_ASCII), 0, 3); coder_.output(writer); coder_.finishEncoding(writer); assertEquals("[\"123\"]", writer.toString()); }