List of utility methods to do ByteBuffer Put
void | putTriByte(ByteBuffer buf, int value) Writes a 'tri-byte' to the specified buffer. buf.put((byte) (value >> 16)); buf.put((byte) (value >> 8)); buf.put((byte) value); |
ByteBuffer | putTruncatedInt(ByteBuffer bytes, int value, int numBytes) put Truncated Int if (numBytes <= 0) throw new IOException("too few bytes specified for truncated int value!"); else if (numBytes >= 4) { if (bytes.remaining() < 4) throw new IOException("not enough space in buffer to write truncated int value"); return bytes.putInt(value); if (bytes.remaining() < numBytes) ... |
void | putUInt16(ByteBuffer buffer, long value) put U Int byte first = (byte) ((value >> 8) & 0xff); byte second = (byte) (value & 0xff); if (buffer.order() == ByteOrder.LITTLE_ENDIAN) { buffer.put(first); buffer.put(second); } else { buffer.put(second); buffer.put(first); ... |
void | putUInt32(ByteBuffer buffer, long value) put U Int byte first = (byte) ((value >> 24) & 0xff); byte second = (byte) ((value >> 16) & 0xff); byte third = (byte) ((value >> 8) & 0xff); byte fourth = (byte) (value & 0xff); if (buffer.order() == ByteOrder.LITTLE_ENDIAN) { buffer.put(first); buffer.put(second); buffer.put(third); ... |
void | putUnsignedByte(ByteBuffer bb, int value) put Unsigned Byte bb.put((byte) (value & 0xff));
|
void | putUnsignedInt(ByteBuffer buffer, long value) Write the given long value as a 4 byte unsigned integer. buffer.putInt((int) (value & 0xffffffffL));
|
void | putUnsignedInt(final ByteBuffer dst, final long value) Put an unsigned int in the ByteBuffer at the current position. dst.putInt((int) (value & INT_FLAG_MASK_LONG));
|
ByteBuffer | putUnsignedShort(ByteBuffer bytes, int value) put Unsigned Short if (bytes.remaining() < 2) throw new IOException("not enough space in buffer to write unsigned short"); if (value > 65535) throw new IOException("int value exceeds maximum unsigned short value of 65535!"); byte b1 = (byte) (0xff & (value >> 8)); byte b2 = (byte) (0xff & value); bytes.put(b1); bytes.put(b2); ... |
ByteBuffer | putUUID(ByteBuffer bytes, UUID uuid) put UUID if (bytes.remaining() < 16) throw new IOException("not enough space in buffer to write UUID value!"); long msb = uuid.getMostSignificantBits(); long lsb = uuid.getLeastSignificantBits(); bytes.putLong(msb); bytes.putLong(lsb); return bytes; |
void | putVarint(ByteBuffer buffer, long number, int byteSize) put Varint for (int i = 0; i < byteSize; i++) { int head = 128; if (i == byteSize - 1) head = 0; long b = ((number >> (7 * i)) & 127) ^ head; buffer.put((byte) (b & 255)); |