本文整理汇总了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();
}
}
示例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);
}
示例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));
}
示例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());
}
示例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);
}