Here you can find the source of decodeNumber(byte firstByte, ByteBuffer buffer)
public static long decodeNumber(byte firstByte, ByteBuffer buffer)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { private static final long OB_MAX_INT_1B = 23; private static final byte OB_INT_SIGN_BIT_POS = 5; private static final byte OB_INT_VALUE_MASK = 0x1f; public static long decodeNumber(byte firstByte, ByteBuffer buffer) { boolean isNeg = testBit(firstByte, OB_INT_SIGN_BIT_POS); byte lenOrValue = (byte) (firstByte & OB_INT_VALUE_MASK); if (lenOrValue <= OB_MAX_INT_1B) { return isNeg ? -lenOrValue : lenOrValue; } else {/*from ww w. ja v a2s . c o m*/ long value = 0; long len = lenOrValue - OB_MAX_INT_1B; if (len == 5 || len == 7) { len++; } for (int index = 0; index < len; index++) { value |= ((buffer.get() & 0xffl) << (index << 3)); } return isNeg ? -value : value; } } private static boolean testBit(byte target, byte pos) { return 0 != (target & (1 << pos)); } }