/** * Set the request's port number. */ public void setPort(int port) { Memory.pokeShort(buffer, INDEX_PORT, (short) port, ByteOrder.BIG_ENDIAN); }
public final void pokeShort(int offset, short value, ByteOrder order) { Memory.pokeShort(address + offset, value, order.needsSwap); }
public final void writeShort(int val) throws IOException { Memory.pokeShort(scratch, 0, (short) val, ByteOrder.BIG_ENDIAN); out.write(scratch, 0, SizeOf.SHORT); written += SizeOf.SHORT; }
/** * Writes a big-endian 16-bit short to this file, starting at the current file * pointer. Only the two least significant bytes of the integer {@code val} * are written. * * @param val * the short to write to this file. * @throws IOException * if an I/O error occurs while writing to this file. * @see #readShort() * @see DataInput#readUnsignedShort() */ public final void writeShort(int val) throws IOException { Memory.pokeShort(scratch, 0, (short) val, ByteOrder.BIG_ENDIAN); write(scratch, 0, SizeOf.SHORT); }
@Override public ByteBuffer putChar(char value) { if (isReadOnly) { throw new ReadOnlyBufferException(); } int newPosition = position + SizeOf.CHAR; if (newPosition > limit) { throw new BufferOverflowException(); } Memory.pokeShort(backingArray, arrayOffset + position, (short) value, order); position = newPosition; return this; }
@Override public ByteBuffer putChar(int index, char value) { if (isReadOnly) { throw new ReadOnlyBufferException(); } checkIndex(index, SizeOf.CHAR); Memory.pokeShort(backingArray, arrayOffset + index, (short) value, order); return this; }
@Override public ByteBuffer putShort(short value) { if (isReadOnly) { throw new ReadOnlyBufferException(); } int newPosition = position + SizeOf.SHORT; if (newPosition > limit) { throw new BufferOverflowException(); } Memory.pokeShort(backingArray, arrayOffset + position, value, order); position = newPosition; return this; }
/** * Returns an array containing the <i>modified UTF-8</i> form of {@code s}, using a * big-endian 16-bit length. Throws UTFDataFormatException if {@code s} is too long * for a two-byte length. */ public static byte[] encode(String s) throws UTFDataFormatException { int utfCount = (int) ModifiedUtf8.countBytes(s, true); byte[] result = new byte[SizeOf.SHORT + utfCount]; Memory.pokeShort(result, 0, (short) utfCount, ByteOrder.BIG_ENDIAN); ModifiedUtf8.encode(result, SizeOf.SHORT, s); return result; }
@Override public ByteBuffer putShort(int index, short value) { if (isReadOnly) { throw new ReadOnlyBufferException(); } checkIndex(index, SizeOf.SHORT); Memory.pokeShort(backingArray, arrayOffset + index, value, order); return this; }
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 {
/** * Set the request's port number. */ public void setPort(int port) { Memory.pokeShort(buffer, INDEX_PORT, (short) port, ByteOrder.BIG_ENDIAN); }
public final void writeShort(int val) throws IOException { Memory.pokeShort(scratch, 0, (short) val, ByteOrder.BIG_ENDIAN); out.write(scratch, 0, SizeOf.SHORT); written += SizeOf.SHORT; }
public final void writeShort(int val) throws IOException { Memory.pokeShort(scratch, 0, (short) val, ByteOrder.BIG_ENDIAN); out.write(scratch, 0, SizeOf.SHORT); written += SizeOf.SHORT; }
@Override public ByteBuffer putChar(int index, char value) { if (isReadOnly) { throw new ReadOnlyBufferException(); } checkIndex(index, SizeOf.CHAR); Memory.pokeShort(backingArray, arrayOffset + index, (short) value, order); return this; }
@Override public ByteBuffer putShort(int index, short value) { if (isReadOnly) { throw new ReadOnlyBufferException(); } checkIndex(index, SizeOf.SHORT); Memory.pokeShort(backingArray, arrayOffset + index, value, order); return this; }
@Override public ByteBuffer putShort(short value) { if (isReadOnly) { throw new ReadOnlyBufferException(); } int newPosition = position + SizeOf.SHORT; if (newPosition > limit) { throw new BufferOverflowException(); } Memory.pokeShort(backingArray, arrayOffset + position, value, order); position = newPosition; return this; }
/** * Returns an array containing the <i>modified UTF-8</i> form of {@code s}, using a * big-endian 16-bit length. Throws UTFDataFormatException if {@code s} is too long * for a two-byte length. */ public static byte[] encode(String s) throws UTFDataFormatException { int utfCount = (int) ModifiedUtf8.countBytes(s, true); byte[] result = new byte[SizeOf.SHORT + utfCount]; Memory.pokeShort(result, 0, (short) utfCount, ByteOrder.BIG_ENDIAN); ModifiedUtf8.encode(result, SizeOf.SHORT, s); return result; }
@Override public ByteBuffer putChar(char value) { if (isReadOnly) { throw new ReadOnlyBufferException(); } int newPosition = position + SizeOf.CHAR; if (newPosition > limit) { throw new BufferOverflowException(); } Memory.pokeShort(backingArray, arrayOffset + position, (short) value, order); position = newPosition; return this; }
@Override public ByteBuffer putShort(int index, short value) { if (isReadOnly) { throw new ReadOnlyBufferException(); } checkIndex(index, SizeOf.SHORT); Memory.pokeShort(backingArray, arrayOffset + index, value, order); return this; }
@Override public ByteBuffer putChar(int index, char value) { if (isReadOnly) { throw new ReadOnlyBufferException(); } checkIndex(index, SizeOf.CHAR); Memory.pokeShort(backingArray, arrayOffset + index, (short) value, order); return this; }