public int readInt() { int result = Memory.peekInt(buffer, offset + position, order); position += SizeOf.INT; return result; }
public final long peekLong(int offset, ByteOrder order) { return Memory.peekLong(address + offset, order.needsSwap); }
/** * Returns the request's port number. */ public int getPort() { return Memory.peekShort(buffer, INDEX_PORT, ByteOrder.BIG_ENDIAN); }
public final void pokeInt(int offset, int value, ByteOrder order) { Memory.pokeInt(address + offset, value, order.needsSwap); }
public void readIntArray(int[] dst, int dstOffset, int intCount) { final int byteCount = intCount * SizeOf.INT; Memory.unsafeBulkGet(dst, dstOffset, byteCount, buffer, offset + position, SizeOf.INT, order.needsSwap); position += byteCount; }
public final void pokeLong(int offset, long value, ByteOrder order) { Memory.pokeLong(address + offset, value, order.needsSwap); }
/** * Set the request's port number. */ public void setPort(int port) { Memory.pokeShort(buffer, INDEX_PORT, (short) port, ByteOrder.BIG_ENDIAN); }
buffer = new byte[1 + SizeOf.SHORT + (int) count]; buffer[offset++] = TC_STRING; Memory.pokeShort(buffer, offset, (short) count, ByteOrder.BIG_ENDIAN); offset += SizeOf.SHORT; } else { buffer = new byte[1 + SizeOf.LONG + (int) count]; buffer[offset++] = TC_LONGSTRING; Memory.pokeLong(buffer, offset, count, ByteOrder.BIG_ENDIAN); offset += SizeOf.LONG;
public byte readByte() { byte result = Memory.peekByte(address + position); ++position; return result; }
public void readByteArray(byte[] dst, int dstOffset, int byteCount) { Memory.peekByteArray(address + position, dst, dstOffset, byteCount); position += byteCount; }
@Override public ByteBuffer compact() { if (isReadOnly) { throw new ReadOnlyBufferException(); } Memory.memmove(this, 0, this, position, remaining()); position = limit - position; limit = capacity; mark = UNSET_MARK; return this; }
public final void writeInt(int val) throws IOException { Memory.pokeInt(scratch, 0, val, ByteOrder.BIG_ENDIAN); out.write(scratch, 0, SizeOf.INT); written += SizeOf.INT; }
final void get(long[] dst, int dstOffset, int longCount) { int byteCount = checkGetBounds(SizeOf.LONG, dst.length, dstOffset, longCount); Memory.unsafeBulkGet(dst, dstOffset, byteCount, backingArray, arrayOffset + position, SizeOf.LONG, order.needsSwap); position += byteCount; }
public final void writeLong(long val) throws IOException { Memory.pokeLong(scratch, 0, val, ByteOrder.BIG_ENDIAN); out.write(scratch, 0, SizeOf.LONG); written += SizeOf.LONG; }
public final void pokeShort(int offset, short value, ByteOrder order) { Memory.pokeShort(address + offset, value, order.needsSwap); }
public final byte peekByte(int offset) { return Memory.peekByte(address + offset); }
public final void peekByteArray(int offset, byte[] dst, int dstOffset, int byteCount) { Memory.peekByteArray(address + offset, dst, dstOffset, byteCount); }
Memory.memmove(dstObject, dstOffset, srcObject, srcOffset, srcByteCount); src.position(src.limit()); dst.position(dst.position() + srcByteCount);
public short readShort() { short result = Memory.peekShort(buffer, offset + position, order); position += SizeOf.SHORT; return result; }
private static UUID makeUuid(byte[] hash, int version) { long msb = Memory.peekLong(hash, 0, ByteOrder.BIG_ENDIAN); long lsb = Memory.peekLong(hash, 8, ByteOrder.BIG_ENDIAN); // Set the version field. msb &= ~(0xfL << 12); msb |= ((long) version) << 12; // Set the variant field to 2. Note that the variant field is variable-width, // so supporting other variants is not just a matter of changing the constant 2 below! lsb &= ~(0x3L << 62); lsb |= 2L << 62; return new UUID(msb, lsb); }