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


Java ArrayBufferInput类代码示例

本文整理汇总了Java中org.msgpack.core.buffer.ArrayBufferInput的典型用法代码示例。如果您正苦于以下问题:Java ArrayBufferInput类的具体用法?Java ArrayBufferInput怎么用?Java ArrayBufferInput使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: mergeFrom

import org.msgpack.core.buffer.ArrayBufferInput; //导入依赖的package包/类
/**
 * Merges the {@code message} with the byte array using the given {@code schema}.
 */
public static <T> void mergeFrom(byte[] data, int offset, int length, T message, Schema<T> schema, boolean numeric)
        throws IOException
{

    ArrayBufferInput bios = new ArrayBufferInput(data, offset, length);

    MessageUnpacker unpacker = MessagePack.newDefaultUnpacker(bios);

    try
    {
        mergeFrom(unpacker, message, schema, numeric);
    }
    finally
    {
        unpacker.close();
    }
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:21,代码来源:MsgpackIOUtil.java

示例2: getUnpacker

import org.msgpack.core.buffer.ArrayBufferInput; //导入依赖的package包/类
public static Unpacker getUnpacker(byte[] data) {
    return new Unpacker(new ArrayBufferInput(data), MessagePack.DEFAULT_UNPACKER_CONFIG);
}
 
开发者ID:cheahjs,项目名称:JLoopix,代码行数:4,代码来源:Unpacker.java

示例3: MessagePackParser

import org.msgpack.core.buffer.ArrayBufferInput; //导入依赖的package包/类
public MessagePackParser(IOContext ctxt, int features, byte[] bytes) throws IOException {
    this(ctxt, features, new ArrayBufferInput(bytes));
}
 
开发者ID:komamitsu,项目名称:jackson-dataformat-msgpack,代码行数:4,代码来源:MessagePackParser.java

示例4: testGeneratorShouldWriteArray

import org.msgpack.core.buffer.ArrayBufferInput; //导入依赖的package包/类
@Test
public void testGeneratorShouldWriteArray() throws IOException {
    List<Object> array = new ArrayList<Object>();
    // #1
    array.add("komamitsu");
    // #2
    array.add(Integer.MAX_VALUE);
    // #3
    array.add(Long.MIN_VALUE);
    // #4
    array.add(3.14159f);
    // #5
    array.add(3.14159d);
    // #6
    Map<String, Object> childObject = new HashMap<String, Object>();
    childObject.put("str", "foobar");
    childObject.put("num", 123456);
    array.add(childObject);
    // #7
    array.add(false);

    long bitmap = 0;
    byte[] bytes = objectMapper.writeValueAsBytes(array);
    MessageUnpacker messageUnpacker = new MessageUnpacker(new ArrayBufferInput(bytes));
    assertEquals(array.size(), messageUnpacker.unpackArrayHeader());
    // #1
    assertEquals("komamitsu", messageUnpacker.unpackString());
    // #2
    assertEquals(Integer.MAX_VALUE, messageUnpacker.unpackInt());
    // #3
    assertEquals(Long.MIN_VALUE, messageUnpacker.unpackLong());
    // #4
    assertEquals(3.14159f, messageUnpacker.unpackFloat(), 0.01f);
    // #5
    assertEquals(3.14159d, messageUnpacker.unpackDouble(), 0.01f);
    // #6
    assertEquals(2, messageUnpacker.unpackMapHeader());
    for (int i = 0; i < childObject.size(); i++) {
        String key = messageUnpacker.unpackString();
        if (key.equals("str")) {
            assertEquals("foobar", messageUnpacker.unpackString());
            bitmap |= 0x1 << 0;
        }
        else if (key.equals("num")) {
            assertEquals(123456, messageUnpacker.unpackInt());
            bitmap |= 0x1 << 1;
        }
        else {
            assertTrue(false);
        }
    }
    assertEquals(0x3, bitmap);
    // #7
    assertEquals(false, messageUnpacker.unpackBoolean());
}
 
开发者ID:komamitsu,项目名称:jackson-dataformat-msgpack,代码行数:56,代码来源:MessagePackGeneratorTest.java

示例5: newPipe

import org.msgpack.core.buffer.ArrayBufferInput; //导入依赖的package包/类
/**
 * Creates a msgpack pipe from a byte array.
 */
public static Pipe newPipe(byte[] data, int offset, int length, boolean numeric) throws IOException
{
    ArrayBufferInput in = new ArrayBufferInput(data, offset, length);
    return newPipe(in, numeric);
}
 
开发者ID:protostuff,项目名称:protostuff,代码行数:9,代码来源:MsgpackIOUtil.java


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