/** * Gets bytes. * * @param bytes The target byte array. * @throws IllegalStateException If this reader is not in byte access mode. */ public void getBytes(byte[] bytes) { checkByteAccess(); for (int i = 0; i < bytes.length; i++) { bytes[i] = buffer.readByte(); } }
/** * Gets bytes in reverse. * * @param bytes The target byte array. * @throws IllegalStateException If this reader is not in byte access mode. */ public void getBytesReverse(byte[] bytes) { checkByteAccess(); for (int i = bytes.length - 1; i >= 0; i--) { bytes[i] = buffer.readByte(); } }
/** * Gets the length of this reader. * * @return The length of this reader. */ public int getLength() { checkByteAccess(); return buffer.writableBytes(); }
/** * Gets a string from the buffer. * * @return The string. * @throws IllegalStateException If this reader is not in byte access mode. */ public String getString() { checkByteAccess(); return BufferUtil.readString(buffer); }
/** * Gets a signed smart from the buffer. * * @return The smart. * @throws IllegalStateException If this reader is not in byte access mode. */ public int getSignedSmart() { checkByteAccess(); int peek = buffer.getByte(buffer.readerIndex()); if (peek < 128) { return buffer.readByte() - 64; } return buffer.readShort() - 49152; }
/** * Gets an unsigned smart from the buffer. * * @return The smart. * @throws IllegalStateException If this reader is not in byte access mode. */ public int getUnsignedSmart() { checkByteAccess(); int peek = buffer.getByte(buffer.readerIndex()); if (peek < 128) { return buffer.readByte(); } return buffer.readShort() - 32768; }
checkByteAccess(); long longValue = 0; int length = type.getBytes();