public static PositiveLongContainer decode(ByteSource in)
 	throws IOException, OffsetLengthDecodeException
 {
  long value;
  int size = 0;
  // read the prefix
  int temp = in.readByte();
  // determine the prefix length
  while (0 != (temp & 0x80))
  {
   temp <<= 1;
   size++;
  }
  // store the rest of this byte in value
  value = temp >> size;
  // limit the prefix size
  if (4 < size)
   throw new OffsetLengthDecodeException("Invalid encoded length: size prefix too large", size);
  // calculate the value length (minus 1 byte alreday read)
  temp &= 0x7F;
  if (0 < size)
  {
   temp >>= 8 - size;
   value &= (1 << (8 - size - size)) - 1;
   size = (1 << (size - 1)) + temp;
  }
  // value contains the high-order bits
  // size contains the number of bytes to read
  // current size limit is MAX_ENCODED_SIZE
  if (MAX_ENCODED_SIZE <= size)
   throw new OffsetLengthDecodeException("Invalid encoded length: size too large", size);
  // read the rest of data
  for(temp = size; 0 < temp; temp--)
   value = (value << 8) | (in.readByte() & 0xFF);
  // guard against negative values
  if (0 > value)
   throw new OffsetLengthDecodeException("Invalid encoded length: negative value", value);
  // check if we just read a marker
  if (0 < size && THRESHOLDS[--size] >= value)
   if (Integer.MAX_VALUE < value)
    throw new OffsetLengthDecodeException("Marker value too large", value);
   else
    return new PositiveLongContainer.Marker((int)value);
  else
   return new PositiveLongContainer(value);
 }