Java ByteBuffer to Int readVarIntRest(ByteBuffer buff, int b)

Here you can find the source of readVarIntRest(ByteBuffer buff, int b)

Description

read Var Int Rest

License

Mozilla Public License

Declaration

private static int readVarIntRest(ByteBuffer buff, int b) 

Method Source Code

//package com.java2s;
/*/*w w  w .  ja v a  2s. c  o m*/
 * Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
 * and the EPL 1.0 (http://h2database.com/html/license.html).
 * Initial Developer: H2 Group
 */

import java.nio.ByteBuffer;

public class Main {
    private static int readVarIntRest(ByteBuffer buff, int b) {
        int x = b & 0x7f;
        b = buff.get();
        if (b >= 0) {
            return x | (b << 7);
        }
        x |= (b & 0x7f) << 7;
        b = buff.get();
        if (b >= 0) {
            return x | (b << 14);
        }
        x |= (b & 0x7f) << 14;
        b = buff.get();
        if (b >= 0) {
            return x | b << 21;
        }
        x |= ((b & 0x7f) << 21) | (buff.get() << 28);
        return x;
    }
}

Related

  1. readVarInt(ByteBuffer buff)
  2. readVarInt(ByteBuffer buff)
  3. readVarint(ByteBuffer buffer)
  4. readVarInt(ByteBuffer buffer)
  5. readVarInt(ByteBuffer stream)
  6. toInt(ByteBuffer buffer)
  7. toInt(ByteBuffer buffer)
  8. toInt(ByteBuffer bytes)
  9. toInt(ByteBuffer value)