当前位置: 首页>>代码示例>>Java>>正文


Java UnsignedBytes.MAX_VALUE属性代码示例

本文整理汇总了Java中com.google.common.primitives.UnsignedBytes.MAX_VALUE属性的典型用法代码示例。如果您正苦于以下问题:Java UnsignedBytes.MAX_VALUE属性的具体用法?Java UnsignedBytes.MAX_VALUE怎么用?Java UnsignedBytes.MAX_VALUE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.google.common.primitives.UnsignedBytes的用法示例。


在下文中一共展示了UnsignedBytes.MAX_VALUE属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prefixNext

/**
 * The next key for bytes domain It first plus one at LSB and if LSB overflows, a zero byte is
 * appended at the end Original bytes will be reused if possible
 *
 * @param key key to encode
 * @return encoded results
 */
public static byte[] prefixNext(byte[] key) {
  int i;
  for (i = key.length - 1; i >= 0; i--) {
    if (key[i] != UnsignedBytes.MAX_VALUE) {
      key[i]++;
      break;
    }
  }
  if (i == -1) {
    return getNextKeyInByteOrder(key);
  }
  return key;
}
 
开发者ID:pingcap,项目名称:tikv-client-lib-java,代码行数:20,代码来源:KeyUtils.java

示例2: increment

/**
 * Returns a RandomAccessData that is the smallest value of same length which
 * is strictly greater than this. Note that if this is empty or is all 0xFF then
 * a token value of positive infinity is returned.
 *
 * <p>The {@link UnsignedLexicographicalComparator} supports comparing {@link RandomAccessData}
 * with support for positive infinitiy.
 */
public RandomAccessData increment() throws IOException {
  RandomAccessData copy = copy();
  for (int i = copy.size - 1; i >= 0; --i) {
    if (copy.buffer[i] != UnsignedBytes.MAX_VALUE) {
      copy.buffer[i] = UnsignedBytes.checkedCast(UnsignedBytes.toInt(copy.buffer[i]) + 1);
      return copy;
    }
  }
  return POSITIVE_INFINITY;
}
 
开发者ID:apache,项目名称:beam,代码行数:18,代码来源:RandomAccessData.java

示例3: testMessageUtil

@Test
public void testMessageUtil() {
    final byte[] result = new byte[] { UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE,
        UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE,
        UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE,
        UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE, 0, 23, 3, 32, 5, 14, 21 };
    final ByteBuf formattedMessage = Unpooled.buffer();
    MessageUtil.formatMessage(3, Unpooled.wrappedBuffer(new byte[] { 32, 5, 14, 21 }), formattedMessage);
    assertArrayEquals(result, ByteArray.getAllBytes(formattedMessage));
}
 
开发者ID:opendaylight,项目名称:bgpcep,代码行数:10,代码来源:UtilsTest.java

示例4: decrement

/**
 * Performs an arbitrary-precision decrement of a byte array.
 *
 * @param in The array to decrement.
 * @return The same input array.
 */
@Nonnull
public static byte[] decrement(@Nonnull byte[] in) {
    for (int i = in.length - 1; i >= 0; i--) {
        if (UnsignedBytes.toInt(in[i]) > 0) {
            in[i]--;
            break;
        }
        in[i] = UnsignedBytes.MAX_VALUE;
    }

    return in;
}
 
开发者ID:shevek,项目名称:dhcp4j,代码行数:18,代码来源:AddressUtils.java

示例5: getBsonType

/**
 * Translate a byte to the {@link BsonType} it represents, as specified on the
 * <a href="http://bsonspec.org/spec.html">BSON Spec</a>
 *
 * @param typeByte
 * @return
 * @throws NettyBsonReaderException
 */
@Nonnull
protected static BsonType getBsonType(byte typeByte) throws NettyBsonReaderException {
  switch (typeByte) {
    case 0x01:
      return DOUBLE;
    case 0x02:
      return STRING;
    case 0x03:
      return DOCUMENT;
    case 0x04:
      return ARRAY;
    case 0x05:
      return BINARY;
    case 0x06:
      return UNDEFINED;
    case 0x07:
      return OBJECT_ID;
    case 0x08:
      return BOOLEAN;
    case 0x09:
      return DATETIME;
    case 0x0A:
      return NULL;
    case 0x0B:
      return REGEX;
    case 0x0C:
      return DB_POINTER;
    case 0x0D:
      return JAVA_SCRIPT;
    case 0x0E:
      return DEPRECATED;
    case 0x0F:
      return JAVA_SCRIPT_WITH_SCOPE;
    case 0x10:
      return INT32;
    case 0x11:
      return TIMESTAMP;
    case 0x12:
      return INT64;
    case 0x13:
      return DECIMAL128;
    case UnsignedBytes.MAX_VALUE:
      return MIN;
    case 0x7F:
      return MAX;
    default:
      throw new NettyBsonReaderException("It is not defined the type associated with the byte "
          + UnsignedBytes.toString(typeByte, 16));
  }
}
 
开发者ID:torodb,项目名称:mongowp,代码行数:58,代码来源:ParsingTools.java

示例6: getByte

protected static byte getByte(BsonType bsonType) throws NettyBsonReaderException {
  switch (bsonType) {
    case DOUBLE:
      return 0x01;
    case STRING:
      return 0x02;
    case DOCUMENT:
      return 0x03;
    case ARRAY:
      return 0x04;
    case BINARY:
      return 0x05;
    case UNDEFINED:
      return 0x06;
    case OBJECT_ID:
      return 0x07;
    case BOOLEAN:
      return 0x08;
    case DATETIME:
      return 0x09;
    case NULL:
      return 0x0A;
    case REGEX:
      return 0x0B;
    case DB_POINTER:
      return 0x0C;
    case JAVA_SCRIPT:
      return 0x0D;
    case DEPRECATED:
      return 0x0E;
    case JAVA_SCRIPT_WITH_SCOPE:
      return 0x0F;
    case INT32:
      return 0x10;
    case TIMESTAMP:
      return 0x11;
    case INT64:
      return 0x12;
    case DECIMAL128:
      return 0x13;
    case MIN:
      return UnsignedBytes.MAX_VALUE;
    case MAX:
      return 0x7F;
    default:
      throw new NettyBsonReaderException("It is not defined the byte associated with the type "
          + bsonType);
  }
}
 
开发者ID:torodb,项目名称:mongowp,代码行数:49,代码来源:ParsingTools.java


注:本文中的com.google.common.primitives.UnsignedBytes.MAX_VALUE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。