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


Java MessagePack.createBufferPacker方法代码示例

本文整理汇总了Java中org.msgpack.MessagePack.createBufferPacker方法的典型用法代码示例。如果您正苦于以下问题:Java MessagePack.createBufferPacker方法的具体用法?Java MessagePack.createBufferPacker怎么用?Java MessagePack.createBufferPacker使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.msgpack.MessagePack的用法示例。


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

示例1: testOptional0103

import org.msgpack.MessagePack; //导入方法依赖的package包/类
public MyMessage03 testOptional0103(MyMessage01 src) throws Exception {
    MessagePack msgpack = new MessagePack();
    TemplateRegistry registry = new TemplateRegistry(null);
    ReflectionTemplateBuilder builder = new ReflectionTemplateBuilder(registry);
    Template<MyMessage01> tmpl01 = builder.buildTemplate(MyMessage01.class);
    Template<MyMessage03> tmpl03 = builder.buildTemplate(MyMessage03.class);
    BufferPacker packer = msgpack.createBufferPacker();
    tmpl01.write(packer, src);
    byte[] bytes = packer.toByteArray();
    ByteArrayInputStream in = new ByteArrayInputStream(bytes);
    Unpacker unpacker = msgpack.createUnpacker(in);
    unpacker.resetReadByteCount();
           MyMessage03 dst = tmpl03.read(unpacker, null);
           assertEquals(bytes.length, unpacker.getReadByteCount());
           return dst;
}
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:17,代码来源:TestOptionalReflectionBufferPackUnpack.java

示例2: testMessagePackableTypeFieldsClass

import org.msgpack.MessagePack; //导入方法依赖的package包/类
@Override
public void testMessagePackableTypeFieldsClass(
        MessagePackableTypeFieldsClass v) throws Exception {
    System.getProperties().setProperty(TemplatePrecompiler.DEST,
            "./target/test-classes");
    MessagePack msgpack = new MessagePack();
    try {
        TemplatePrecompiler.saveTemplateClass(new TemplateRegistry(null),
                MessagePackableTypeFieldsClass.class);
        Template<MessagePackableTypeFieldsClass> tmpl = msgpack
                .lookup(MessagePackableTypeFieldsClass.class);
        BufferPacker packer = msgpack.createBufferPacker();
        tmpl.write(packer, v);
        byte[] bytes = packer.toByteArray();
        BufferUnpacker unpacker = msgpack.createBufferUnpacker();
        unpacker.wrap(bytes);
        MessagePackableTypeFieldsClass ret = tmpl.read(unpacker, null);
        assertEquals(v, ret);
    } finally {
        TemplatePrecompiler
                .deleteTemplateClass(MessagePackableTypeFieldsClass.class);
        msgpack.unregister(MessagePackableTypeFieldsClass.class);
    }
}
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:25,代码来源:TestTemplatePreCompilerBufferPackBufferUnpack.java

示例3: testMapTypeFieldsClassNotNullable

import org.msgpack.MessagePack; //导入方法依赖的package包/类
@Override
   public void testMapTypeFieldsClassNotNullable(MapTypeFieldsClassNotNullable v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry(null);
ReflectionTemplateBuilder builder = new ReflectionTemplateBuilder(registry);
Template<MapTypeFieldsClassNotNullable> tmpl = builder.buildTemplate(MapTypeFieldsClassNotNullable.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker unpacker = msgpack.createBufferUnpacker();
unpacker.resetReadByteCount();
unpacker.wrap(bytes);
MapTypeFieldsClassNotNullable ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
assertEquals(bytes.length, unpacker.getReadByteCount());
   }
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:17,代码来源:TestReflectionBufferPackBufferUnpack.java

示例4: testEnumTypeFieldsClassNotNullable

import org.msgpack.MessagePack; //导入方法依赖的package包/类
@Override
   public void testEnumTypeFieldsClassNotNullable(EnumTypeFieldsClassNotNullable v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry(null);
registry.register(EnumTypeFieldsClassNotNullable.SampleEnum.class,
	new OrdinalEnumTemplateBuilder(registry).buildTemplate(EnumTypeFieldsClassNotNullable.SampleEnum.class));
ReflectionTemplateBuilder builder = new ReflectionTemplateBuilder(registry);
Template<EnumTypeFieldsClassNotNullable> tmpl = builder.buildTemplate(EnumTypeFieldsClassNotNullable.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker unpacker = msgpack.createBufferUnpacker();
unpacker.resetReadByteCount();
unpacker.wrap(bytes);
EnumTypeFieldsClassNotNullable ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
assertEquals(bytes.length, unpacker.getReadByteCount());
   }
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:19,代码来源:TestOrdinalEnumBufferPackBufferUnpack.java

示例5: testListTypeFieldsClassNotNullable

import org.msgpack.MessagePack; //导入方法依赖的package包/类
@Override
   public void testListTypeFieldsClassNotNullable(ListTypeFieldsClassNotNullable v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry(null);
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
Template<ListTypeFieldsClassNotNullable> tmpl = builder.buildTemplate(ListTypeFieldsClassNotNullable.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker unpacker = msgpack.createBufferUnpacker();
unpacker.resetReadByteCount();
unpacker.wrap(bytes);
ListTypeFieldsClassNotNullable ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
assertEquals(bytes.length, unpacker.getReadByteCount());
   }
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:17,代码来源:TestReflectionBeansBufferPackBufferUnpack.java

示例6: testModifiersFieldsClassNotNullable

import org.msgpack.MessagePack; //导入方法依赖的package包/类
@Override
   public void testModifiersFieldsClassNotNullable(ModifiersFieldsClassNotNullable v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry(null);
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
Template<ModifiersFieldsClassNotNullable> tmpl = builder.buildTemplate(ModifiersFieldsClassNotNullable.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker unpacker = msgpack.createBufferUnpacker();
unpacker.resetReadByteCount();
unpacker.wrap(bytes);
ModifiersFieldsClassNotNullable ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
assertEquals(bytes.length, unpacker.getReadByteCount());
   }
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:17,代码来源:TestReflectionBeansBufferPackBufferUnpack.java

示例7: testReferenceTypeFieldsClassNotNullable

import org.msgpack.MessagePack; //导入方法依赖的package包/类
@Override
   public void testReferenceTypeFieldsClassNotNullable(ReferenceTypeFieldsClassNotNullable v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry(null);
JavassistTemplateBuilder builder = new JavassistTemplateBuilder(registry);
Template<ReferenceTypeFieldsClassNotNullable> tmpl = builder.buildTemplate(ReferenceTypeFieldsClassNotNullable.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker unpacker = msgpack.createBufferUnpacker();
unpacker.resetReadByteCount();
unpacker.wrap(bytes);
ReferenceTypeFieldsClassNotNullable ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
assertEquals(bytes.length, unpacker.getReadByteCount());
   }
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:17,代码来源:TestJavassistBufferPackBufferUnpack.java

示例8: testReferenceCycleTypeFieldsClass

import org.msgpack.MessagePack; //导入方法依赖的package包/类
@Override
   public void testReferenceCycleTypeFieldsClass(ReferenceCycleTypeFieldsClass v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry(null);
ReflectionTemplateBuilder builder = new ReflectionTemplateBuilder(registry);
Template<ReferenceCycleTypeFieldsClass> tmpl = builder.buildTemplate(ReferenceCycleTypeFieldsClass.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.resetReadByteCount();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
ReferenceCycleTypeFieldsClass ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
assertEquals(bytes.length, u.getReadByteCount());
   }
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:19,代码来源:TestReflectionBufferPackConvert.java

示例9: testReferenceTypeFieldsClassNotNullable

import org.msgpack.MessagePack; //导入方法依赖的package包/类
@Override
   public void testReferenceTypeFieldsClassNotNullable(ReferenceTypeFieldsClassNotNullable v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry(null);
ReflectionTemplateBuilder builder = new ReflectionTemplateBuilder(registry);
Template<ReferenceTypeFieldsClassNotNullable> tmpl = builder.buildTemplate(ReferenceTypeFieldsClassNotNullable.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.resetReadByteCount();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
ReferenceTypeFieldsClassNotNullable ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
assertEquals(bytes.length, u.getReadByteCount());
   }
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:19,代码来源:TestReflectionBufferPackConvert.java

示例10: testReferenceTypeFieldsClass

import org.msgpack.MessagePack; //导入方法依赖的package包/类
@Override
   public void testReferenceTypeFieldsClass(ReferenceTypeFieldsClass v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry(null);
ReflectionTemplateBuilder builder = new ReflectionTemplateBuilder(registry);
Template<ReferenceTypeFieldsClass> tmpl = builder.buildTemplate(ReferenceTypeFieldsClass.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker unpacker = msgpack.createBufferUnpacker();
unpacker.resetReadByteCount();
unpacker.wrap(bytes);
ReferenceTypeFieldsClass ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
assertEquals(bytes.length, unpacker.getReadByteCount());
   }
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:17,代码来源:TestReflectionBufferPackBufferUnpack.java

示例11: testInheritanceClass

import org.msgpack.MessagePack; //导入方法依赖的package包/类
@Override
public void testInheritanceClass(InheritanceClass v) throws Exception {
    System.getProperties().setProperty(TemplatePrecompiler.DEST,
            "./target/test-classes");
    MessagePack msgpack = new MessagePack();
    try {
        TemplatePrecompiler.saveTemplateClass(new TemplateRegistry(null),
                InheritanceClass.class);
        Template<InheritanceClass> tmpl = msgpack
                .lookup(InheritanceClass.class);
        BufferPacker packer = msgpack.createBufferPacker();
        tmpl.write(packer, v);
        byte[] bytes = packer.toByteArray();
        BufferUnpacker unpacker = msgpack.createBufferUnpacker();
        unpacker.wrap(bytes);
        InheritanceClass ret = tmpl.read(unpacker, null);
        assertEquals(v, ret);
    } finally {
        TemplatePrecompiler.deleteTemplateClass(InheritanceClass.class);
        msgpack.unregister(InheritanceClass.class);
    }
}
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:23,代码来源:TestTemplatePreCompilerBufferPackBufferUnpack.java

示例12: testListTypeFieldsClass

import org.msgpack.MessagePack; //导入方法依赖的package包/类
@Override
   public void testListTypeFieldsClass(ListTypeFieldsClass v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry(null);
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
Template<ListTypeFieldsClass> tmpl = builder.buildTemplate(ListTypeFieldsClass.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
Unpacker unpacker = msgpack.createUnpacker(new ByteArrayInputStream(bytes));
unpacker.resetReadByteCount();
ListTypeFieldsClass ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
assertEquals(bytes.length, unpacker.getReadByteCount());
   }
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:16,代码来源:TestReflectionBeansBufferPackUnpack.java

示例13: testReferenceTypeFieldsClassNotNullable

import org.msgpack.MessagePack; //导入方法依赖的package包/类
@Override
   public void testReferenceTypeFieldsClassNotNullable(ReferenceTypeFieldsClassNotNullable v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry(null);
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
Template<ReferenceTypeFieldsClassNotNullable> tmpl = builder.buildTemplate(ReferenceTypeFieldsClassNotNullable.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
Unpacker unpacker = msgpack.createUnpacker(new ByteArrayInputStream(bytes));
unpacker.resetReadByteCount();
ReferenceTypeFieldsClassNotNullable ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
assertEquals(bytes.length, unpacker.getReadByteCount());
   }
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:16,代码来源:TestReflectionBeansBufferPackUnpack.java

示例14: testByteBuffer

import org.msgpack.MessagePack; //导入方法依赖的package包/类
@Override
public void testByteBuffer(ByteBuffer v) throws Exception {
    MessagePack msgpack = new MessagePack();
    Template<ByteBuffer> tmpl = ByteBufferTemplate.instance;
    BufferPacker packer = msgpack.createBufferPacker();
    tmpl.write(packer, v);
    byte[] bytes = packer.toByteArray();
    Unpacker unpacker = msgpack.createUnpacker(new ByteArrayInputStream(bytes));
    unpacker.resetReadByteCount();
    ByteBuffer ret = tmpl.read(unpacker, null);
    assertArrayEquals(toByteArray(v), toByteArray(ret));
    assertEquals(bytes.length, unpacker.getReadByteCount());
}
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:14,代码来源:TestByteBufferTemplate.java

示例15: testBooleanArray

import org.msgpack.MessagePack; //导入方法依赖的package包/类
@Override
public void testBooleanArray(boolean[] v) throws Exception {
    MessagePack msgpack = new MessagePack();
    Template<boolean[]> tmpl = BooleanArrayTemplate.instance;
    BufferPacker packer = msgpack.createBufferPacker();
    tmpl.write(packer, v);
    byte[] bytes = packer.toByteArray();
    Unpacker unpacker = msgpack.createUnpacker(new ByteArrayInputStream(bytes));
    unpacker.resetReadByteCount();
    boolean[] ret0;
    switch (index) {
    case 0:
	ret0 = null;
	break;
    case 1:
	if (v == null) {
	    ret0 = new boolean[0];
	} else {
	    ret0 = new boolean[v.length];
	}
	break;
    case 2:
	if (v == null) {
	    ret0 = new boolean[0];
	} else {
	    ret0 = new boolean[(int) v.length / 2];
	}
	break;
    default:
	throw new IllegalArgumentException();
    }
    boolean[] ret = tmpl.read(unpacker, ret0);
    assertBooleanArrayEquals(v, ret);
    assertEquals(bytes.length, unpacker.getReadByteCount());
}
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:36,代码来源:TestBooleanArrayTemplate.java


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