@Test public void testWriteLong() throws IOException { w.writeLong(0); w.writeLong(-1); w.writeLong(Byte.MAX_VALUE); w.writeLong(Byte.MIN_VALUE); w.writeLong(Short.MAX_VALUE); w.writeLong(Short.MIN_VALUE); w.writeLong(Integer.MAX_VALUE); w.writeLong(Integer.MIN_VALUE); w.writeLong(Long.MAX_VALUE); w.writeLong(Long.MIN_VALUE); checkContents("21" + "00" + "21" + "FF" + "21" + "7F" + "21" + "80" + "22" + "7FFF" + "22" + "8000" + "24" + "7FFFFFFF" + "24" + "80000000" + "28" + "7FFFFFFFFFFFFFFF" + "28" + "8000000000000000"); }
@Override public void writeLong(long i) throws IOException { if (i >= Byte.MIN_VALUE && i <= Byte.MAX_VALUE) { out.write(INT_8); out.write((byte) i); } else if (i >= Short.MIN_VALUE && i <= Short.MAX_VALUE) { out.write(INT_16); writeInt16((short) i); } else if (i >= Integer.MIN_VALUE && i <= Integer.MAX_VALUE) { out.write(INT_32); writeInt32((int) i); } else { out.write(INT_64); writeInt64(i); } }
BdfWriterImpl implements BdfWriter { @Override public void writeLong(long i) throws IOException { if (i >= Byte.MIN_VALUE && i <= Byte.MAX_VALUE) { out.write(INT_8); out.write((byte) i); } else if (i >= Short.MIN_VALUE && i <= Short.MAX_VALUE) { out.write(INT_16); writeInt16((short) i); } else if (i >= Integer.MIN_VALUE && i <= Integer.MAX_VALUE) { out.write(INT_32); writeInt32((int) i); } else { out.write(INT_64); writeInt64(i); } } }
BdfWriterImpl implements BdfWriter { @Override public void writeLong(long i) throws IOException { if (i >= Byte.MIN_VALUE && i <= Byte.MAX_VALUE) { out.write(INT_8); out.write((byte) i); } else if (i >= Short.MIN_VALUE && i <= Short.MAX_VALUE) { out.write(INT_16); writeInt16((short) i); } else if (i >= Integer.MIN_VALUE && i <= Integer.MAX_VALUE) { out.write(INT_32); writeInt32((int) i); } else { out.write(INT_64); writeInt64(i); } } BdfWriterImpl(OutputStream out); }
BdfWriterImpl implements BdfWriter { @Override public void writeLong(long i) throws IOException { if (i >= Byte.MIN_VALUE && i <= Byte.MAX_VALUE) { out.write(INT_8); out.write((byte) i); } else if (i >= Short.MIN_VALUE && i <= Short.MAX_VALUE) { out.write(INT_16); writeInt16((short) i); } else if (i >= Integer.MIN_VALUE && i <= Integer.MAX_VALUE) { out.write(INT_32); writeInt32((int) i); } else { out.write(INT_64); writeInt64(i); } } 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 writeLong(long i) throws IOException { if (i >= Byte.MIN_VALUE && i <= Byte.MAX_VALUE) { out.write(INT_8); out.write((byte) i); } else if (i >= Short.MIN_VALUE && i <= Short.MAX_VALUE) { out.write(INT_16); writeInt16((short) i); } else if (i >= Integer.MIN_VALUE && i <= Integer.MAX_VALUE) { out.write(INT_32); writeInt32((int) i); } else { out.write(INT_64); writeInt64(i); } } 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();  }