@Override public PositionedByteRange get(byte[] dst) { if (0 == dst.length) return this; return this.get(dst, 0, dst.length); // be clear we're calling self, not // super }
@Override public PositionedByteRange set(byte[] bytes, int offset, int length) { this.position = 0; super.set(bytes, offset, length); limit = length; return this; }
/** * Update the length of this range. {@code offset + length} should not be * greater than {@code bytes.length}. If {@code position} is greater than the * new {@code length}, sets {@code position} to {@code length}. * * @param length * The new length of this range. * @return this. */ @Override public PositionedByteRange setLength(int length) { this.position = Math.min(position, length); super.setLength(length); return this; }
@Override public long getVLong() { long p = getVLong(position); position += getVLongSize(p); return p; }
/** * Update the beginning of this range. {@code offset + length} may not be * greater than {@code bytes.length}. Resets {@code position} to 0. * * @param offset * the new start of this range. * @return this. */ @Override public PositionedByteRange setOffset(int offset) { this.position = 0; super.setOffset(offset); return this; }
/** * Similar to {@link java.nio.ByteBuffer#flip()}. Sets length to position, position to * offset. */ @VisibleForTesting PositionedByteRange flip() { clearHashCache(); length = position; position = offset; return this; }
@Override public short getShort() { short s = getShort(position); position += Bytes.SIZEOF_SHORT; return s; }
@Override public int getInt() { int i = getInt(position); position += Bytes.SIZEOF_INT; return i; }
@Override public long getLong() { long l = getLong(position); position += Bytes.SIZEOF_LONG; return l; }
@Override public long getVLong() { long p = getVLong(position); position += getVLongSize(p); return p; }
/** * Update the beginning of this range. {@code offset + length} may not be * greater than {@code bytes.length}. Resets {@code position} to 0. * * @param offset the new start of this range. * @return this. */ @Override public PositionedByteRange setOffset(int offset) { this.position = 0; super.setOffset(offset); return this; }
/** * Similar to {@link java.nio.ByteBuffer#clear()}. Sets position to 0, length to * capacity. */ @VisibleForTesting PositionedByteRange clear() { clearHashCache(); position = 0; length = bytes.length - offset; return this; }
@Override public short getShort() { short s = getShort(position); position += Bytes.SIZEOF_SHORT; return s; }
@Override public int getInt() { int i = getInt(position); position += Bytes.SIZEOF_INT; return i; }
@Override public long getLong() { long l = getLong(position); position += Bytes.SIZEOF_LONG; return l; }
@Override public PositionedByteRange set(byte[] bytes) { this.position = 0; super.set(bytes); this.limit = bytes.length; return this; }
@Override public PositionedByteRange get(int index, byte[] dst) { super.get(index, dst); return this; }
@Override public long getVLong() { long p = getVLong(position); position += getVLongSize(p); return p; }
/** * Update the beginning of this range. {@code offset + length} may not be * greater than {@code bytes.length}. Resets {@code position} to 0. * * @param offset * the new start of this range. * @return this. */ @Override public PositionedByteRange setOffset(int offset) { this.position = 0; super.setOffset(offset); return this; }
/** * Update the length of this range. {@code offset + length} should not be * greater than {@code bytes.length}. If {@code position} is greater than the * new {@code length}, sets {@code position} to {@code length}. * * @param length * The new length of this range. * @return this. */ @Override public PositionedByteRange setLength(int length) { this.position = Math.min(position, length); super.setLength(length); return this; }