@Test public void testDecode() throws Exception { checkDecoding(0x7F, 0x7F); checkDecoding(0x80, 0x81, 0x00); checkDecoding(0x2000, 0xC0, 0x00); checkDecoding(0x3FFF, 0xFF, 0x7F); checkDecoding(0x4000, 0x81, 0x80, 0x00); checkDecoding(0x1FFFFF, 0xFF, 0xFF, 0x7F); checkDecoding(0x200000, 0x81, 0x80, 0x80, 0x00); checkDecoding(0x08000000, 0xC0, 0x80, 0x80, 0x00); checkDecoding(0x0FFFFFFF, 0xFF, 0xFF, 0xFF, 0x7F); checkDecoding(Integer.MAX_VALUE, 0x87, 0xFF, 0xFF, 0xFF, 0x7F); }
public static int decode(ReadBuffer in) { int b; int value = 0; for (int i = 0; i < 5; i++) { b = in.getByte(); value |= b & 0x7F; if ((b & 0x80) == 0) { return value; } value <<= 7; } throw new IllegalArgumentException("Cannot decode value greater than Integer.MAX_VALUE"); }
VLQ { public static int decode(ReadBuffer in) { int b; int value = 0; for (int i = 0; i < 5; i++) { b = in.getByte(); value |= b & 0x7F; if ((b & 0x80) == 0) { return value; } value <<= 7; } throw new IllegalArgumentException("Cannot decode value greater than Integer.MAX_VALUE"); } }
VLQ { public static int decode(ReadBuffer in) { int b; int value = 0; for (int i = 0; i < 5; i++) { b = in.getByte(); value |= b & 0x7F; if ((b & 0x80) == 0) { return value; } value <<= 7; } throw new IllegalArgumentException("Cannot decode value greater than Integer.MAX_VALUE"); }  }
VLQ { public static int decode(ReadBuffer in) { int b; int value = 0; for (int i = 0; i < 5; i++) { b = in.getByte(); value |= b & 0x7F; if ((b & 0x80) == 0) { return value; } value <<= 7; } throw new IllegalArgumentException("Cannot decode value greater than Integer.MAX_VALUE"); }  static void encode(int value, ByteBuffer out); static int decode(ReadBuffer in); static int encodedSize(int value); }
VLQ { public static int decode(ReadBuffer in) { int b; int value = 0; for (int i = 0; i < 5; i++) { b = in.getByte(); value |= b & 0x7F; if ((b & 0x80) == 0) { return value; } value <<= 7; } throw new IllegalArgumentException("Cannot decode value greater than Integer.MAX_VALUE"); }  static void encode(int value, ByteBuffer out); static int decode(ReadBuffer in); static int encodedSize(int value);  }