本文整理汇总了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));
}
}
}
}
示例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));
}
}
}
}
示例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));
}
}
示例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");
}
示例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);
}
示例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));
}
示例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();
}
示例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));
}
示例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));
}
}
示例10: toString
import com.google.common.primitives.UnsignedBytes; //导入方法依赖的package包/类
@Override
public String toString() {
return "Unknown(0x" + UnsignedBytes.toString(getCode(), 16) + ")";
}
示例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();
}