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


Java ExtensionValue类代码示例

本文整理汇总了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;
}
 
开发者ID:cheahjs,项目名称:JLoopix,代码行数:18,代码来源:Unpacker.java

示例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);
    }
}
 
开发者ID:komamitsu,项目名称:fluency,代码行数:52,代码来源:BufferTestHelper.java


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