/** * @see ByteBuffer#get(byte[], int,int) */ public IoBuffer get(byte[] dst, int offset, int length) { if (remaining() < length) { throw new BufferUnderflowException(); } int remainsToCopy = length; int currentOffset = offset; while (remainsToCopy > 0) { position.updatePos(); position.getNode().getBuffer().position(position.getPositionInNode()); ByteBuffer currentBuffer = position.getNode().getBuffer(); int blocksize = Math.min(remainsToCopy, currentBuffer.remaining()); position.getNode().getBuffer().get(dst, currentOffset, blocksize); currentOffset += blocksize; remainsToCopy -= blocksize; position.incrementPosition(blocksize); position.getNode().getBuffer().position(0); } return this; }
/** * @see ByteBuffer#put(byte[], int, int) */ public IoBuffer put(byte[] src, int offset, int length) { if (readonly) { throw new ReadOnlyBufferException(); } if (remaining() < length) { throw new BufferUnderflowException(); } int remainsToCopy = length; int currentOffset = offset; position.getNode().getBuffer().position(position.getPositionInNode()); while (remainsToCopy > 0) { position.updatePos(); ByteBuffer currentBuffer = position.getNode().getBuffer(); int blocksize = Math.min(remainsToCopy, currentBuffer.remaining()); position.getNode().getBuffer().put(src, currentOffset, blocksize); currentOffset += blocksize; remainsToCopy -= blocksize; position.incrementPosition(blocksize); } position.getNode().getBuffer().position(0); return this; }
public void incrPosition() { incrementPosition(1); }