本文整理汇总了Java中org.msgpack.value.ExtensionValue类的典型用法代码示例。如果您正苦于以下问题:Java ExtensionValue类的具体用法?Java ExtensionValue怎么用?Java ExtensionValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExtensionValue类属于org.msgpack.value包,在下文中一共展示了ExtensionValue类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unpackBigNumber
import org.msgpack.value.ExtensionValue; //导入依赖的package包/类
public BigInteger unpackBigNumber() throws IOException {
ImmutableValue value = this.unpackValue();
if (!value.isExtensionValue())
throw new RuntimeException("Expected extension value");
ExtensionValue extValue = value.asExtensionValue();
if (extValue.getType() != 0)
throw new RuntimeException("Expected bignum value");
byte[] data = extValue.getData();
byte sign = data[0];
if (sign != '+' && sign != '-')
throw new RuntimeException("Sign was not pos or neg");
BigInteger bn = new BigInteger(sign == '+' ? 1 : -1, Arrays.copyOfRange(data, 1, data.length));
return bn;
}
示例2: analyzeResult
import org.msgpack.value.ExtensionValue; //导入依赖的package包/类
private void analyzeResult(String tag, ImmutableValue timestamp, Map<String, Object> data, long start, long end, boolean eventTime)
{
Integer count = tagCounts.get(tag);
if (count == null) {
count = 0;
}
tagCounts.put(tag, count + 1);
if (eventTime) {
assertThat(timestamp.isExtensionValue(), is(true));
ExtensionValue tsInEventTime = timestamp.asExtensionValue();
assertThat(tsInEventTime.getType(), CoreMatchers.is((byte) 0x00));
ByteBuffer secondsAndNanoSeconds = ByteBuffer.wrap(tsInEventTime.getData());
int seconds = secondsAndNanoSeconds.getInt();
int nanoSeconds = secondsAndNanoSeconds.getInt();
assertTrue(start / 1000 <= seconds && seconds <= end / 1000);
assertThat(nanoSeconds, is(999999999));
}
else {
assertThat(timestamp.isIntegerValue(), is(true));
long tsInEpochMilli = timestamp.asIntegerValue().asLong();
assertTrue(start <= tsInEpochMilli && tsInEpochMilli<= end);
}
assertEquals(3, data.size());
String name = (String) data.get("name");
int age = (Integer) data.get("age");
String comment = (String) data.get("comment");
if (name.compareTo(minName) < 0) {
minName = name;
}
if (name.compareTo(maxName) > 0) {
maxName = name;
}
if (age < minAge) {
minAge = age;
}
if (age > maxAge) {
maxAge = age;
}
if (comment.equals("hello")) {
// expected
}
else if (comment.equals(longStr)) {
longCommentCount++;
}
else {
assertTrue(false);
}
}