/** * @see ByteBuffer#hasRemaining() */ public boolean hasRemaining() { return remaining() > 0; }
/** * @see ByteBuffer#putChar(int, char) */ public IoBuffer putChar(int index, char value) { return putChar(getPointerByPosition(index), value); }
@SuppressWarnings("unchecked") @Override public IN decode(IoBuffer input) { try { return (IN) parseMethod.invoke(null, input.asInputStream(), registry); } catch (Exception e) { throw new ProtocolDecoderException(e); } } }
/** * {@inheritDoc} */ @Override public int hashCode() { int hash = 0; Pointer oldPos = position.duplicate(); while (hasRemaining()) { hash *= 31; // NOSONAR, standard way of hashing hash += get(); } position = oldPos; return hash; }
/** * @see ByteBuffer#rewind() */ public IoBuffer rewind() { position(0); mark = getPointerByPosition(-1); return this; }
/** * @see ByteBuffer#get(byte[]) */ public IoBuffer get(byte[] dst) { get(dst, 0, dst.length); return this; }
/** * @see ByteBuffer#putInt(int, int) */ public IoBuffer putInt(int index, int value) { return putInt(getPointerByPosition(index), value); }
private IoBuffer putShort(Pointer pointer, short value) { if (position.getPosition() > pointer.getPosition() || pointer.getPosition() > limit.getPosition() - Short.SIZE / Byte.SIZE) { throw new BufferUnderflowException(); } for (int i = 0; i < Short.SIZE; i += Byte.SIZE) { put(pointer, (byte) (value >> (bo == ByteOrder.BIG_ENDIAN ? Byte.SIZE - i : i))); } return this; }
/** * @see ByteBuffer#putInt(int) */ public IoBuffer putInt(int value) { return putInt(position, value); }
/** * @see ByteBuffer#getChar() */ public char getChar() { return getChar(position); }
/** * @see ByteBuffer#getLong() */ public long getLong() { return getLong(position); }
/** * @see ByteBuffer#getShort() */ public short getShort() { return getShort(position); }
/** * @see ByteBuffer#putShort(short) */ public IoBuffer putShort(short value) { return putShort(position, value); }
/** * @see ByteBuffer#getFloat() */ public float getFloat() { return getFloat(position); }
/** * @see ByteBuffer#clear() */ public IoBuffer clear() { position = getPointerByPosition(0); limit = getPointerByPosition(capacity); mark = null; return this; }
/** * @see ByteBuffer#limit() */ public int limit() { return limit.getPosition(); }
/** * @see ByteBuffer#flip() */ public IoBuffer flip() { limit = position; position = getPointerByPosition(0); return this; }
/** * @see ByteBuffer#position() */ public int position() { return position.getPosition(); }