BufferPosition { public void skipOverFreeSpace() { ByteBuffer curBuf = _buffers[bufferIndex()]; for(int iterNum = 0;iterNum < _buffers.length && bufferOffset() >= curBuf.limit(); ++iterNum) { incrementIndex(); curBuf = _buffers[bufferIndex()]; } } BufferPosition(BufferPositionParser parser, ByteBuffer[] buffers);  BufferPosition(long pos, BufferPositionParser parser, ByteBuffer[] buffers); boolean init(); void copy(BufferPosition rhs ); long getRealPosition(); int bufferIndex(); int bufferOffset(); long bufferGenId(); void setPosition(long address); void setPosition(long genId, int index, int offset); long getPosition(); @Override String toString(); long incrementGenId(); long incrementIndex(); long incrementOffset(int increment); long sanitize(); long sanitize(boolean okToRegress); @Override int hashCode(); @Override boolean equals(Object obj); boolean equals(BufferPosition position); boolean equalsIgnoreGenId(BufferPosition position); void skipOverFreeSpace(); static final String MODULE; static final Logger LOG; }
@Test public void testSkipOverFreeSpace() { ByteBuffer[] buffers = allocateByteBuffers(128, 128, 50); BufferPositionParser parser = createParser(128, 128, 50); BufferPosition pos = new BufferPosition(parser, buffers); adjustLimits(buffers, 50, 100, 0); pos.setPosition(parser.encode(0, 0, 0)); pos.skipOverFreeSpace(); assertPosition(pos, 0, 0, 0); adjustLimits(buffers, 0, 0, 0); pos.setPosition(parser.encode(0, 0, 0)); pos.skipOverFreeSpace(); assertPosition(pos, 1, 0, 0); adjustLimits(buffers, 10, 0, 0); pos.setPosition(parser.encode(0, 0, 50)); pos.skipOverFreeSpace(); assertPosition(pos, 1, 0, 0); adjustLimits(buffers, 50, 100, 0); pos.setPosition(parser.encode(10, 0, 10)); pos.skipOverFreeSpace(); assertPosition(pos, 10, 0, 10); pos.setPosition(parser.encode(12, 0, 50)); pos.skipOverFreeSpace(); assertPosition(pos, 12, 1, 0); pos.setPosition(parser.encode(255, 1, 100)); pos.skipOverFreeSpace(); assertPosition(pos, 256, 0, 0); }