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


Java UnsignedBytes.toString方法代码示例

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


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

示例1: getBinarySubtype

import com.google.common.primitives.UnsignedBytes; //导入方法依赖的package包/类
protected static BinarySubtype getBinarySubtype(byte readByte) {
  switch (readByte) {
    case 0x00:
      return BinarySubtype.GENERIC;
    case 0x01:
      return BinarySubtype.FUNCTION;
    case 0x02:
      return BinarySubtype.OLD_BINARY;
    case 0x03:
      return BinarySubtype.OLD_UUID;
    case 0x04:
      return BinarySubtype.UUID;
    case 0x05:
      return BinarySubtype.MD5;
    default: {
      if (UnsignedBytes.compare(readByte, FIRST_USER_DEFINED) >= 0) {
        return BinarySubtype.USER_DEFINED;
      } else {
        throw new AssertionError(
            "Unrecognized binary type 0x" + UnsignedBytes.toString(readByte, 16));
      }
    }
  }
}
 
开发者ID:torodb,项目名称:mongowp,代码行数:25,代码来源:ParsingTools.java

示例2: getBinarySubtype

import com.google.common.primitives.UnsignedBytes; //导入方法依赖的package包/类
protected static BinarySubtype getBinarySubtype(byte readByte) {
  switch (readByte) {
    case 0x00:
      return BinarySubtype.GENERIC;
    case 0x01:
      return BinarySubtype.FUNCTION;
    case 0x02:
      return BinarySubtype.OLD_BINARY;
    case 0x03:
      return BinarySubtype.OLD_UUID;
    case 0x04:
      return BinarySubtype.UUID;
    case 0x05:
      return BinarySubtype.MD5;
    default:
    {
      if (UnsignedBytes.compare(readByte, FIRST_USER_DEFINED) >= 0) {
        return BinarySubtype.USER_DEFINED;
      } else {
        throw new AssertionError(
                "Unrecognized binary type 0x" + UnsignedBytes.toString(readByte, 16));
      }
    }
  }
}
 
开发者ID:torodb,项目名称:mongowp,代码行数:26,代码来源:MongoBsonTranslator.java

示例3: fromWire

import com.google.common.primitives.UnsignedBytes; //导入方法依赖的package包/类
@Nonnull
public static Payload fromWire(@Nonnull ByteBuffer buffer) {
    if (!buffer.hasRemaining())
        return EndOfList.INSTANCE;

    byte type = buffer.get();
    AbstractWireable.assertWireByte(buffer, (byte) 0, "reserved byte");
    short length = buffer.getShort();
    byte[] data = new byte[length - 4];
    buffer.get(data);

    switch (buffer.get()) {
        case 0:
            return EndOfList.INSTANCE;
        case 1:
            return Code.fromByte(AuthenticationAlgorithm.class, data[0]);
        case 2:
            return Code.fromByte(IntegrityAlgorithm.class, data[0]);
        default:
            throw new IllegalArgumentException("Unknown algorithm type 0x" + UnsignedBytes.toString(type, 16));
    }
}
 
开发者ID:shevek,项目名称:ipmi4j,代码行数:23,代码来源:AsfRsspSessionAuthentication.java

示例4: readBoolean

import com.google.common.primitives.UnsignedBytes; //导入方法依赖的package包/类
@Override
BsonBoolean readBoolean(@Loose @ModifiesIndexes ByteBuf byteBuf) throws NettyBsonReaderException {
  byte readByte = byteBuf.readByte();
  if (readByte == 0x00) {
    return FalseBsonBoolean.getInstance();
  }
  if (readByte == 0x01) {
    return TrueBsonBoolean.getInstance();
  }
  throw new NettyBsonReaderException("Unexpected boolean byte. 0x00 or "
      + "0x01 was expected, but 0x" + UnsignedBytes.toString(readByte, 16) + " was read");
}
 
开发者ID:torodb,项目名称:mongowp,代码行数:13,代码来源:DefaultNettyBsonLowLevelReader.java

示例5: fromWireChecksum

import com.google.common.primitives.UnsignedBytes; //导入方法依赖的package包/类
public void fromWireChecksum(@Nonnull ByteBuffer buffer, @Nonnegative int start, @Nonnull String description) {
    byte expect = toChecksum(buffer, start);
    byte actual = buffer.get();
    if (expect != actual)
        throw new IllegalArgumentException("Checksum failure: " + description
                + ": expected=" + UnsignedBytes.toString(expect, 16)
                + " actual=" + UnsignedBytes.toString(actual, 16) + "; command=" + getClass().getSimpleName() + "; data=" + this);
}
 
开发者ID:shevek,项目名称:ipmi4j,代码行数:9,代码来源:AbstractIpmiCommand.java

示例6: assertWireByte

import com.google.common.primitives.UnsignedBytes; //导入方法依赖的package包/类
/** Reads a byte from the wire, and asserts it equal to the given expected value. */
public static void assertWireByte(@Nonnull ByteBuffer buffer, byte expectValue, @Nonnull String description) {
    byte actualValue = buffer.get();
    if (actualValue != expectValue)
        throw new IllegalArgumentException("In " + description + ": "
                + "Expected 0x" + UnsignedBytes.toString(expectValue, 16)
                + " but got 0x" + UnsignedBytes.toString(actualValue, 16));
}
 
开发者ID:shevek,项目名称:ipmi4j,代码行数:9,代码来源:AbstractWireable.java

示例7: toHexString

import com.google.common.primitives.UnsignedBytes; //导入方法依赖的package包/类
@Nonnull
public static String toHexString(@CheckForNull byte... data) {
    if (data == null)
        return "<null>";
    StringBuilder buf = new StringBuilder();
    buf.append("(").append(data.length).append(" bytes) ");
    for (byte b : data) {
        String s = UnsignedBytes.toString(b, 16);
        if (s.length() < 2)
            buf.append('0');
        buf.append(s).append(' ');
    }
    buf.setLength(buf.length() - 1);
    return buf.toString();
}
 
开发者ID:shevek,项目名称:ipmi4j,代码行数:16,代码来源:AbstractWireable.java

示例8: fromByte

import com.google.common.primitives.UnsignedBytes; //导入方法依赖的package包/类
@Nonnull
public static <T extends Enum<T> & Code.Wrapper> T fromByte(@Nonnull Class<T> type, byte code) {
    for (T value : type.getEnumConstants())
        if (value.getCode() == code)
            return value;
    throw new IllegalArgumentException("Unknown " + type.getSimpleName() + " code 0x" + UnsignedBytes.toString(code, 16));
}
 
开发者ID:shevek,项目名称:ipmi4j,代码行数:8,代码来源:Code.java

示例9: getBsonType

import com.google.common.primitives.UnsignedBytes; //导入方法依赖的package包/类
/**
 * 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,代码行数:59,代码来源:ParsingTools.java

示例10: toString

import com.google.common.primitives.UnsignedBytes; //导入方法依赖的package包/类
@Override
public String toString() {
    return "Unknown(0x" + UnsignedBytes.toString(getCode(), 16) + ")";
}
 
开发者ID:shevek,项目名称:ipmi4j,代码行数:5,代码来源:SDRDeviceSubtype.java

示例11: toString

import com.google.common.primitives.UnsignedBytes; //导入方法依赖的package包/类
@Nonnull
public static <T extends Enum<T> & Code.DescriptiveWrapper> String toString(@Nonnull T value) {
    return value.name() + "(0x" + UnsignedBytes.toString(value.getCode(), 16) + "): " + value.getDescription();
}
 
开发者ID:shevek,项目名称:ipmi4j,代码行数:5,代码来源:Code.java


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