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