public static void write(ByteSequence packet, int b) throws IOException { spaceNeeded(packet, 1); packet.data[packet.offset++] = (byte)b; }
public static void readFully(ByteSequence packet, byte[] b, int off, int len) throws IOException { spaceNeeded(packet, len); System.arraycopy(packet.data, packet.offset, b, off, len); packet.offset += len; }
public static void write(ByteSequence packet, byte[] b, int off, int len) throws IOException { spaceNeeded(packet, len); System.arraycopy(b, off, packet.data, packet.offset, len); packet.offset += len; }
public static int readUnsignedByte(ByteSequence packet) throws IOException { spaceNeeded(packet, 1); return read(packet); }
public static void writeShortLittle(ByteSequence packet, int v) throws IOException { spaceNeeded(packet, 2); write(packet, (v >>> 0) & 0xFF); write(packet, (v >>> 8) & 0xFF); }
public static void writeShortBig(ByteSequence packet, int v) throws IOException { spaceNeeded(packet, 2); write(packet, (v >>> 8) & 0xFF); write(packet, (v >>> 0) & 0xFF); }
public static void writeCharBig(ByteSequence packet, int v) throws IOException { spaceNeeded(packet, 2); write(packet, (v >>> 8) & 0xFF); write(packet, (v >>> 0) & 0xFF); }
public static void writeCharLittle(ByteSequence packet, int v) throws IOException { spaceNeeded(packet, 2); write(packet, (v >>> 0) & 0xFF); write(packet, (v >>> 8) & 0xFF); }
public static short readShortLittle(ByteSequence packet) throws IOException { spaceNeeded(packet, 2); return (short)((read(packet) << 0) + (read(packet) << 8)); }
public static int readUnsignedShortLittle(ByteSequence packet) throws IOException { spaceNeeded(packet, 2); return (read(packet) << 0) + (read(packet) << 8); }
public static char readCharBig(ByteSequence packet) throws IOException { spaceNeeded(packet, 2); return (char)((read(packet) << 8) + (read(packet) << 0)); }
public static int readUnsignedShortBig(ByteSequence packet) throws IOException { spaceNeeded(packet, 2); return (read(packet) << 8) + (read(packet) << 0); }
public static void writeIntLittle(ByteSequence packet, int v) throws IOException { spaceNeeded(packet, 4); write(packet, (v >>> 0) & 0xFF); write(packet, (v >>> 8) & 0xFF); write(packet, (v >>> 16) & 0xFF); write(packet, (v >>> 24) & 0xFF); }
public static void writeIntBig(ByteSequence packet, int v) throws IOException { spaceNeeded(packet, 4); write(packet, (v >>> 24) & 0xFF); write(packet, (v >>> 16) & 0xFF); write(packet, (v >>> 8) & 0xFF); write(packet, (v >>> 0) & 0xFF); }
public static int readIntBig(ByteSequence packet) throws IOException { spaceNeeded(packet, 4); return (read(packet) << 24) + (read(packet) << 16) + (read(packet) << 8) + (read(packet) << 0); }
public static int readIntLittle(ByteSequence packet) throws IOException { spaceNeeded(packet, 4); return (read(packet) << 0) + (read(packet) << 8) + (read(packet) << 16) + (read(packet) << 24); }
public static long readLongLittle(ByteSequence packet) throws IOException { spaceNeeded(packet, 8); return (read(packet) << 0) + (read(packet) << 8) + (read(packet) << 16) + ((long)read(packet) << 24) + ((long)read(packet) << 32) + ((long)read(packet) << 40) + ((long)read(packet) << 48) + ((long)read(packet) << 56); }
public static void writeLongBig(ByteSequence packet, long v) throws IOException { spaceNeeded(packet, 8); write(packet, (int)(v >>> 56) & 0xFF); write(packet, (int)(v >>> 48) & 0xFF); write(packet, (int)(v >>> 40) & 0xFF); write(packet, (int)(v >>> 32) & 0xFF); write(packet, (int)(v >>> 24) & 0xFF); write(packet, (int)(v >>> 16) & 0xFF); write(packet, (int)(v >>> 8) & 0xFF); write(packet, (int)(v >>> 0) & 0xFF); }
public static long readLongBig(ByteSequence packet) throws IOException { spaceNeeded(packet, 8); return ((long)read(packet) << 56) + ((long)read(packet) << 48) + ((long)read(packet) << 40) + ((long)read(packet) << 32) + ((long)read(packet) << 24) + ((read(packet)) << 16) + ((read(packet)) << 8) + ((read(packet)) << 0); }
public static void writeLongLittle(ByteSequence packet, long v) throws IOException { spaceNeeded(packet, 8); write(packet, (int)(v >>> 0) & 0xFF); write(packet, (int)(v >>> 8) & 0xFF); write(packet, (int)(v >>> 16) & 0xFF); write(packet, (int)(v >>> 24) & 0xFF); write(packet, (int)(v >>> 32) & 0xFF); write(packet, (int)(v >>> 40) & 0xFF); write(packet, (int)(v >>> 48) & 0xFF); write(packet, (int)(v >>> 56) & 0xFF); }