Package org.msgpack

Examples of org.msgpack.MessagePack.createPacker()


  MessagePack msgpack = new MessagePack();
  TemplateRegistry registry = new TemplateRegistry();
  JavassistTemplateBuilder builder = new JavassistTemplateBuilder(registry);
  Template<MessagePackableTypeFieldsClassNotNullable> tmpl = builder.buildTemplate(MessagePackableTypeFieldsClassNotNullable.class);
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  Packer packer = msgpack.createPacker(out);
  tmpl.write(packer, v);
  byte[] bytes = out.toByteArray();
  BufferUnpacker u = msgpack.createBufferUnpacker();
  u.wrap(bytes);
  Value value = u.readValue();
View Full Code Here


  registry.register(EnumTypeFieldsClass.SampleEnum.class,
    new OrdinalEnumTemplateBuilder(registry).buildTemplate(EnumTypeFieldsClass.SampleEnum.class));
  ReflectionTemplateBuilder builder = new ReflectionTemplateBuilder(registry);
  Template<EnumTypeFieldsClass> tmpl = builder.buildTemplate(EnumTypeFieldsClass.class);
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  Packer packer = msgpack.createPacker(out);
  tmpl.write(packer, v);
  byte[] bytes = out.toByteArray();
  Unpacker unpacker = msgpack.createUnpacker(new ByteArrayInputStream(bytes));
  EnumTypeFieldsClass ret = tmpl.read(unpacker, null);
  assertEquals(v, ret);
View Full Code Here

  registry.register(EnumTypeFieldsClassNotNullable.SampleEnum.class,
    new OrdinalEnumTemplateBuilder(registry).buildTemplate(EnumTypeFieldsClassNotNullable.SampleEnum.class));
  ReflectionTemplateBuilder builder = new ReflectionTemplateBuilder(registry);
  Template<EnumTypeFieldsClassNotNullable> tmpl = builder.buildTemplate(EnumTypeFieldsClassNotNullable.class);
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  Packer packer = msgpack.createPacker(out);
  tmpl.write(packer, v);
  byte[] bytes = out.toByteArray();
  Unpacker unpacker = msgpack.createUnpacker(new ByteArrayInputStream(bytes));
  EnumTypeFieldsClassNotNullable ret = tmpl.read(unpacker, null);
  assertEquals(v, ret);
View Full Code Here

  @Override
  public void testShortArray(short[] v) throws Exception {
      MessagePack msgpack = new MessagePack();
      Template<short[]> tmpl = ShortArrayTemplate.instance;
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      Packer packer = msgpack.createPacker(out);
      tmpl.write(packer, v);
      byte[] bytes = out.toByteArray();
      Unpacker unpacker = msgpack.createUnpacker(new ByteArrayInputStream(bytes));
      short[] ret0;
      switch (index) {
View Full Code Here

  @Override
  public void testShortArray(short[] v) throws Exception {
      MessagePack msgpack = new MessagePack();
      Template<short[]> tmpl = ShortArrayTemplate.instance;
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      Packer packer = msgpack.createPacker(out);
      tmpl.write(packer, v);
      byte[] bytes = out.toByteArray();
      BufferUnpacker unpacker = msgpack.createBufferUnpacker(bytes);
      short[] ret0;
      switch (index) {
View Full Code Here

  @Override
  public void testLongArray(long[] v) throws Exception {
      MessagePack msgpack = new MessagePack();
      Template<long[]> tmpl = LongArrayTemplate.instance;
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      Packer packer = msgpack.createPacker(out);
      tmpl.write(packer, v);
      byte[] bytes = out.toByteArray();
      Unpacker unpacker = msgpack.createUnpacker(new ByteArrayInputStream(bytes));
      long[] ret0;
      switch (index) {
View Full Code Here

  @Override
  public void testLongArray(long[] v) throws Exception {
      MessagePack msgpack = new MessagePack();
      Template<long[]> tmpl = LongArrayTemplate.instance;
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      Packer packer = msgpack.createPacker(out);
      tmpl.write(packer, v);
      byte[] bytes = out.toByteArray();
      BufferUnpacker unpacker = msgpack.createBufferUnpacker(bytes);
      long[] ret0;
      switch (index) {
View Full Code Here

      MessagePack msgpack = new MessagePack();
      Template<K> keyElementTemplate = msgpack.lookup(keyElementClass);
      Template<V> valueElementTemplate = msgpack.lookup(valueElementClass);
      Template<Map<K, V>> tmpl = new MapTemplate(keyElementTemplate, valueElementTemplate);
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      Packer packer = msgpack.createPacker(out);
      tmpl.write(packer, v);
      byte[] bytes = out.toByteArray();
      Unpacker unpacker = msgpack.createUnpacker(new ByteArrayInputStream(bytes));
      Map<K, V> ret = tmpl.read(unpacker, null);
      assertEquals(v, ret);
View Full Code Here

      MessagePack msgpack = new MessagePack();
      Template<K> keyElementTemplate = msgpack.lookup(keyElementClass);
      Template<V> valueElementTemplate = msgpack.lookup(valueElementClass);
      Template<Map<K, V>> tmpl = new MapTemplate(keyElementTemplate, valueElementTemplate);
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      Packer packer = msgpack.createPacker(out);
      tmpl.write(packer, v);
      byte[] bytes = out.toByteArray();
      BufferUnpacker unpacker = msgpack.createBufferUnpacker(bytes);
      Map<K, V> ret = tmpl.read(unpacker, null);
      assertEquals(v, ret);
View Full Code Here

  @Override
  public void testIntegerArray(int[] v) throws Exception {
      MessagePack msgpack = new MessagePack();
      Template<int[]> tmpl = IntegerArrayTemplate.instance;
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      Packer packer = msgpack.createPacker(out);
      tmpl.write(packer, v);
      byte[] bytes = out.toByteArray();
      Unpacker unpacker = msgpack.createUnpacker(new ByteArrayInputStream(bytes));
      int[] ret0;
      switch (index) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.