@Test public void testWriteBigSmart() { OutputStream os = new OutputStream(); os.writeBigSmart(42); os.writeBigSmart(70000); os.writeBigSmart(65535); InputStream is = new InputStream(os.getArray()); Assert.assertEquals(42, is.readBigSmart()); Assert.assertEquals(70000, is.readBigSmart()); Assert.assertEquals(65535, is.readBigSmart()); }
public void writeBigSmart(int value) { Preconditions.checkArgument(value >= 0); if (value >= 32768) { ensureRemaining(4); this.writeInt((1 << 31) | value); } else { ensureRemaining(2); this.writeShort(value); } }
OutputStream extends java.io.OutputStream { public void writeBigSmart(int value) { Preconditions.checkArgument(value >= 0); if (value >= 32768) { ensureRemaining(4); this.writeInt((1 << 31) | value); } else { ensureRemaining(2); this.writeShort(value); } } }
OutputStream extends java.io.OutputStream { public void writeBigSmart(int value) { Preconditions.checkArgument(value >= 0); if (value >= 32768) { ensureRemaining(4); this.writeInt((1 << 31) | value); } else { ensureRemaining(2); this.writeShort(value); } } OutputStream(int capacity);  OutputStream(); }
OutputStream extends java.io.OutputStream { public void writeBigSmart(int value) { Preconditions.checkArgument(value >= 0); if (value >= 32768) { ensureRemaining(4); this.writeInt((1 << 31) | value); } else { ensureRemaining(2); this.writeShort(value); } } OutputStream(int capacity);  OutputStream(); byte[] getArray(); void skip(int length); int getOffset(); void setOffset(int offset); void writeBytes(byte[] b); void writeBytes(byte[] b, int offset, int length); void writeByte(int i); void writeBigSmart(int value); void writeShort(int i); void writeShortSmart(int value); void write24BitInt(int i); void writeInt(int i); void writeVarInt(int var1); void writeLengthFromMark(int var1); void writeString(String str); byte[] flip(); @Override void write(int b); }
OutputStream extends java.io.OutputStream { public void writeBigSmart(int value) { Preconditions.checkArgument(value >= 0); if (value >= 32768) { ensureRemaining(4); this.writeInt((1 << 31) | value); } else { ensureRemaining(2); this.writeShort(value); } } OutputStream(int capacity);  OutputStream(); byte[] getArray(); void skip(int length); int getOffset(); void setOffset(int offset); void writeBytes(byte[] b); void writeBytes(byte[] b, int offset, int length); void writeByte(int i); void writeBigSmart(int value); void writeShort(int i); void writeShortSmart(int value); void write24BitInt(int i); void writeInt(int i); void writeVarInt(int var1); void writeLengthFromMark(int var1); void writeString(String str); byte[] flip(); @Override void write(int b);  }