@Test public void checkNotenoughData() { BytePartialDecoder decoder = new BytePartialDecoder(4); ByteBuffer buffer = ByteBuffer.wrap(new byte[] {0x00, 0x00}); assertFalse(decoder.consume(buffer)); }
public boolean consume(ByteBuffer buffer) { if (value.length - offset == 0) { throw new IllegalStateException(); } int length = Math.min(buffer.remaining(), value.length - offset); buffer.get(value, offset, length); offset += length; return value.length - offset == 0; }
BytePartialDecoder implements PartialDecoder<byte[]> { public boolean consume(ByteBuffer buffer) { if (value.length - offset == 0) { throw new IllegalStateException(); } int length = Math.min(buffer.remaining(), value.length - offset); buffer.get(value, offset, length); offset += length; return value.length - offset == 0; } }
BytePartialDecoder implements PartialDecoder<byte[]> { public boolean consume(ByteBuffer buffer) { if (value.length - offset == 0) { throw new IllegalStateException(); } int length = Math.min(buffer.remaining(), value.length - offset); buffer.get(value, offset, length); offset += length; return value.length - offset == 0; } BytePartialDecoder(int size); }
BytePartialDecoder implements PartialDecoder<byte[]> { public boolean consume(ByteBuffer buffer) { if (value.length - offset == 0) { throw new IllegalStateException(); } int length = Math.min(buffer.remaining(), value.length - offset); buffer.get(value, offset, length); offset += length; return value.length - offset == 0; } BytePartialDecoder(int size); boolean consume(ByteBuffer buffer); byte[] getValue(); @Override void reset(); }
BytePartialDecoder implements PartialDecoder<byte[]> { public boolean consume(ByteBuffer buffer) { if (value.length - offset == 0) { throw new IllegalStateException(); } int length = Math.min(buffer.remaining(), value.length - offset); buffer.get(value, offset, length); offset += length; return value.length - offset == 0; } BytePartialDecoder(int size); boolean consume(ByteBuffer buffer); byte[] getValue(); @Override void reset();  }