List of utility methods to do ByteBuffer to Int
int | getUnsignedShort(ByteBuffer bb) get Unsigned Short if (bb.remaining() >= 2) { return ((0x0FF & bb.get()) << 8) + (0x0FF & bb.get()); } else { throw new IndexOutOfBoundsException(); |
int | getUnsignedShort(ByteBuffer bb) get Unsigned Short return (bb.getShort() & 0xffff);
|
int | getUnsignedShort(ByteBuffer buf) This is a relative method for getting 2 unsigned bytes. return buf.getShort() & 0x0000FFFF;
|
int | getUnsignedShort(ByteBuffer buffer) get Unsigned Short return buffer.getShort() & 0xFFFF;
|
int | getUnsignedShort(ByteBuffer buffer, int offset) Reads a big-endian unsigned short integer from the buffer at the provided offset. return (buffer.get(offset) & 0xFF) << 8 | buffer.get(offset + 1) & 0xFF;
|
int | getUnsignedShort(ByteBuffer bytes) get Unsigned Short if (bytes.remaining() < 2) throw new IOException("too few bytes specified for unsigned short value!"); byte b1 = bytes.get(); byte b2 = bytes.get(); int value = (int) ((0xff & b1) << 8 | (0xff & b2)); return value; |
int | getUnsignedSmart(ByteBuffer buf) Gets a unsigned smart from the buffer. int peek = buf.get(buf.position()) & 0xFF; if (peek < 128) return buf.get() & 0xFF; else return (buf.getShort() & 0xFFFF) - 32768; |
int | getUnsignedSmartInt(ByteBuffer buffer) get Unsigned Smart Int if ((buffer.get(buffer.position()) & 0xff) < 128) { return buffer.get() & 0xff; int shortValue = buffer.getShort() & 0xFFFF; return shortValue - 32768; |
int | getUnsignedVarInt(ByteBuffer buffer, int numBytes) Read an unsigned variable length int from a buffer int pos = buffer.position(); int rtn = getUnsignedVarInt(buffer, pos, numBytes); buffer.position(pos + numBytes); return rtn; |
int | getUShort(ByteBuffer buffer) get U Short assert (buffer.capacity() - buffer.position() >= 2); byte[] data = new byte[2]; data[1] = buffer.get(); data[0] = buffer.get(); return ((data[0] << 8) & 0x0000ff00) | (data[1] & 0x000000ff); |