com.google.common.primitives.UnsignedBytes#MAX_VALUE源码实例Demo

下面列出了com.google.common.primitives.UnsignedBytes#MAX_VALUE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: tikv-client-lib-java   文件: KeyUtils.java
/**
 * 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;
}
 
源代码2 项目: bgpcep   文件: UtilsTest.java
@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));
}
 
源代码3 项目: dhcp4j   文件: AddressUtils.java
/**
 * 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;
}
 
源代码4 项目: dhcp4j   文件: AddressUtils.java
/**
 * 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;
}
 
源代码5 项目: mongowp   文件: ParsingTools.java
/**
 * 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));
  }
}
 
源代码6 项目: mongowp   文件: ParsingTools.java
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);
  }
}