public void writeBoolean(boolean value) { if (bitCount == 0) { // first bool in byte ensure(1); count++; } if (value) buf[count-1] |= (byte)(1 << bitCount); bitCount++; if (bitCount == 8) bitCount = 0; }
public void writeFixed32(int i) throws IOException { ensure(4); buf[count ] = (byte)((i ) & 0xFF); buf[count+1] = (byte)((i >>> 8) & 0xFF); buf[count+2] = (byte)((i >>> 16) & 0xFF); buf[count+3] = (byte)((i >>> 24) & 0xFF); count += 4; }
public void writeFixed64(long l) throws IOException { ensure(8); int first = (int)(l & 0xFFFFFFFF); int second = (int)((l >>> 32) & 0xFFFFFFFF); buf[count ] = (byte)((first ) & 0xFF); buf[count+4] = (byte)((second ) & 0xFF); buf[count+5] = (byte)((second >>> 8) & 0xFF); buf[count+1] = (byte)((first >>> 8) & 0xFF); buf[count+2] = (byte)((first >>> 16) & 0xFF); buf[count+6] = (byte)((second >>> 16) & 0xFF); buf[count+7] = (byte)((second >>> 24) & 0xFF); buf[count+3] = (byte)((first >>> 24) & 0xFF); count += 8; }
public void writeInt(int n) { ensure(5); n = (n << 1) ^ (n >> 31); // move sign to low-order bit if ((n & ~0x7F) != 0) { buf[count++] = (byte)((n | 0x80) & 0xFF); n >>>= 7; if (n > 0x7F) { buf[count++] = (byte)((n | 0x80) & 0xFF); n >>>= 7; if (n > 0x7F) { buf[count++] = (byte)((n | 0x80) & 0xFF); n >>>= 7; if (n > 0x7F) { buf[count++] = (byte)((n | 0x80) & 0xFF); n >>>= 7; } } } } buf[count++] = (byte) n; }
public void writeLong(long n) throws IOException { ensure(10); n = (n << 1) ^ (n >> 63); // move sign to low-order bit if ((n & ~0x7FL) != 0) {
public void writeFixed32(int i) throws IOException { ensure(4); buf[count ] = (byte)((i ) & 0xFF); buf[count+1] = (byte)((i >>> 8) & 0xFF); buf[count+2] = (byte)((i >>> 16) & 0xFF); buf[count+3] = (byte)((i >>> 24) & 0xFF); count += 4; }
public void writeFixed64(long l) throws IOException { ensure(8); int first = (int)(l & 0xFFFFFFFF); int second = (int)((l >>> 32) & 0xFFFFFFFF); buf[count ] = (byte)((first ) & 0xFF); buf[count+4] = (byte)((second ) & 0xFF); buf[count+5] = (byte)((second >>> 8) & 0xFF); buf[count+1] = (byte)((first >>> 8) & 0xFF); buf[count+2] = (byte)((first >>> 16) & 0xFF); buf[count+6] = (byte)((second >>> 16) & 0xFF); buf[count+7] = (byte)((second >>> 24) & 0xFF); buf[count+3] = (byte)((first >>> 24) & 0xFF); count += 8; }
public void writeInt(int n) throws IOException { ensure(5); n = (n << 1) ^ (n >> 31); // move sign to low-order bit if ((n & ~0x7F) != 0) { buf[count++] = (byte)((n | 0x80) & 0xFF); n >>>= 7; if (n > 0x7F) { buf[count++] = (byte)((n | 0x80) & 0xFF); n >>>= 7; if (n > 0x7F) { buf[count++] = (byte)((n | 0x80) & 0xFF); n >>>= 7; if (n > 0x7F) { buf[count++] = (byte)((n | 0x80) & 0xFF); n >>>= 7; } } } } buf[count++] = (byte) n; }
public void writeLong(long n) throws IOException { ensure(10); n = (n << 1) ^ (n >> 63); // move sign to low-order bit if ((n & ~0x7FL) != 0) {