view src/ie/oshiro/messagepack/practice/MSGFJListTest.java @ 2:79c8067c34ec

add MSInterFaceTest.java
author one
date Fri, 07 Jun 2013 20:26:28 +0900
parents 95fc62831771
children 98144dbff410
line wrap: on
line source

package ie.oshiro.messagepack.practice;

import java.io.IOException;

import org.msgpack.MessagePack;
import org.msgpack.template.ListTemplate;
import org.msgpack.template.ValueTemplate;
import org.msgpack.type.Value;

import fj.data.List;

public class MSGFJListTest {

	public static void main(String[] args) throws IOException { 
		MessagePack msgpack = new MessagePack();
		List<Integer> writeList = List.nil();
		writeList = writeList.cons(1);
		writeList = writeList.cons(2);
		writeList = writeList.cons(3);
		byte[] bytes;
		bytes = msgpack.write(writeList);
		// Cannot find template for class fj.data.List class
		msgpack.register(List.class, new ListTemplate(ValueTemplate.getInstance()));
		for(Value v: (List<Value>) msgpack.read(bytes, List.class)) {
			System.out.println(v.asIntegerValue());
		}
/*
		// Cannot find template for class fj.data.List class
		Value v = msgpack.unconvert(writeList);
		List<Integer> readList = (List<Integer>)msgpack.convert(v, List.class);
		for(Integer i: readList) {
			System.out.println(i);
		}
*/

		
		
	}

}