@Test public void testWriteRaw8() throws IOException { byte[] longest = new byte[Byte.MAX_VALUE]; String longHex = StringUtils.toHexString(longest); w.writeRaw(new byte[] {1, 2, 3}); w.writeRaw(longest); checkContents("51" + "03" + "010203" + "51" + "7F" + longHex); }
@Override public void writeRaw(byte[] b) throws IOException { if (b.length <= Byte.MAX_VALUE) { out.write(RAW_8); out.write((byte) b.length); } else if (b.length <= Short.MAX_VALUE) { out.write(RAW_16); writeInt16((short) b.length); } else { out.write(RAW_32); writeInt32(b.length); } out.write(b); }
BdfWriterImpl implements BdfWriter { @Override public void writeRaw(byte[] b) throws IOException { if (b.length <= Byte.MAX_VALUE) { out.write(RAW_8); out.write((byte) b.length); } else if (b.length <= Short.MAX_VALUE) { out.write(RAW_16); writeInt16((short) b.length); } else { out.write(RAW_32); writeInt32(b.length); } out.write(b); } }
BdfWriterImpl implements BdfWriter { @Override public void writeRaw(byte[] b) throws IOException { if (b.length <= Byte.MAX_VALUE) { out.write(RAW_8); out.write((byte) b.length); } else if (b.length <= Short.MAX_VALUE) { out.write(RAW_16); writeInt16((short) b.length); } else { out.write(RAW_32); writeInt32(b.length); } out.write(b); } BdfWriterImpl(OutputStream out); }
BdfWriterImpl implements BdfWriter { @Override public void writeRaw(byte[] b) throws IOException { if (b.length <= Byte.MAX_VALUE) { out.write(RAW_8); out.write((byte) b.length); } else if (b.length <= Short.MAX_VALUE) { out.write(RAW_16); writeInt16((short) b.length); } else { out.write(RAW_32); writeInt32(b.length); } out.write(b); } BdfWriterImpl(OutputStream out); @Override void flush(); @Override void close(); @Override void writeNull(); @Override void writeBoolean(boolean b); @Override void writeLong(long i); @Override void writeDouble(double d); @Override void writeString(String s); @Override void writeRaw(byte[] b); @Override void writeList(Collection<?> c); @Override void writeListStart(); @Override void writeListEnd(); @Override void writeDictionary(Map<?, ?> m); @Override void writeDictionaryStart(); @Override void writeDictionaryEnd(); }
BdfWriterImpl implements BdfWriter { @Override public void writeRaw(byte[] b) throws IOException { if (b.length <= Byte.MAX_VALUE) { out.write(RAW_8); out.write((byte) b.length); } else if (b.length <= Short.MAX_VALUE) { out.write(RAW_16); writeInt16((short) b.length); } else { out.write(RAW_32); writeInt32(b.length); } out.write(b); } BdfWriterImpl(OutputStream out); @Override void flush(); @Override void close(); @Override void writeNull(); @Override void writeBoolean(boolean b); @Override void writeLong(long i); @Override void writeDouble(double d); @Override void writeString(String s); @Override void writeRaw(byte[] b); @Override void writeList(Collection<?> c); @Override void writeListStart(); @Override void writeListEnd(); @Override void writeDictionary(Map<?, ?> m); @Override void writeDictionaryStart(); @Override void writeDictionaryEnd();  }