@Test public void checkNotenoughData() { IntPartialDecoder decoder = new IntPartialDecoder(); ByteBuffer buffer = ByteBuffer.wrap(new byte[] {0x00, 0x00}); assertFalse(decoder.consume(buffer)); }
public boolean consume(ByteBuffer buffer) { if (remaining == 0) { throw new IllegalStateException(); } while (remaining > 0 && buffer.hasRemaining()) { value = (value << 8) + (buffer.get() & 0x00FF); --remaining; } return remaining == 0; }
IntPartialDecoder implements PartialDecoder<Integer> { public boolean consume(ByteBuffer buffer) { if (remaining == 0) { throw new IllegalStateException(); } while (remaining > 0 && buffer.hasRemaining()) { value = (value << 8) + (buffer.get() & 0x00FF); --remaining; } return remaining == 0; } }
IntPartialDecoder implements PartialDecoder<Integer> { public boolean consume(ByteBuffer buffer) { if (remaining == 0) { throw new IllegalStateException(); } while (remaining > 0 && buffer.hasRemaining()) { value = (value << 8) + (buffer.get() & 0x00FF); --remaining; } return remaining == 0; } IntPartialDecoder(int size);  IntPartialDecoder(); }
IntPartialDecoder implements PartialDecoder<Integer> { public boolean consume(ByteBuffer buffer) { if (remaining == 0) { throw new IllegalStateException(); } while (remaining > 0 && buffer.hasRemaining()) { value = (value << 8) + (buffer.get() & 0x00FF); --remaining; } return remaining == 0; } IntPartialDecoder(int size);  IntPartialDecoder(); boolean consume(ByteBuffer buffer); Integer getValue(); @Override void reset(); }
IntPartialDecoder implements PartialDecoder<Integer> { public boolean consume(ByteBuffer buffer) { if (remaining == 0) { throw new IllegalStateException(); } while (remaining > 0 && buffer.hasRemaining()) { value = (value << 8) + (buffer.get() & 0x00FF); --remaining; } return remaining == 0; } IntPartialDecoder(int size);  IntPartialDecoder(); boolean consume(ByteBuffer buffer); Integer getValue(); @Override void reset();  }