Mercurial > hg > Members > nobuyasu > PracticeJava
changeset 1:95fc62831771
add
author | one |
---|---|
date | Tue, 04 Jun 2013 19:55:40 +0900 |
parents | 7fbe8af3c8d0 |
children | 79c8067c34ec |
files | .classpath lib/functionaljava.jar lib/javassist-3.16.1-GA.jar lib/msgpack-0.6.8-SNAPSHOT-sources.jar lib/msgpack-0.6.8-SNAPSHOT.jar src/ie/oshiro/messagepack/practice/MSGFJListTest.java src/ie/oshiro/messagepack/practice/MSGListTest.java |
diffstat | 7 files changed, 69 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/.classpath Tue Jun 04 02:11:38 2013 +0900 +++ b/.classpath Tue Jun 04 19:55:40 2013 +0900 @@ -2,5 +2,9 @@ <classpath> <classpathentry kind="src" path="src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="lib" path="/Users/nobuyasu/workspace/PracticeJava/lib/functionaljava.jar"/> + <classpathentry kind="lib" path="/Users/nobuyasu/workspace/PracticeJava/lib/javassist-3.16.1-GA.jar"/> + <classpathentry kind="lib" path="/Users/nobuyasu/workspace/PracticeJava/lib/msgpack-0.6.8-SNAPSHOT-sources.jar"/> + <classpathentry kind="lib" path="/Users/nobuyasu/workspace/PracticeJava/lib/msgpack-0.6.8-SNAPSHOT.jar"/> <classpathentry kind="output" path="bin"/> </classpath>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ie/oshiro/messagepack/practice/MSGFJListTest.java Tue Jun 04 19:55:40 2013 +0900 @@ -0,0 +1,39 @@ +package ie.oshiro.messagepack.practice; + +import java.io.IOException; + +import org.msgpack.MessagePack; +import org.msgpack.annotation.Message; +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); + } +*/ + + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ie/oshiro/messagepack/practice/MSGListTest.java Tue Jun 04 19:55:40 2013 +0900 @@ -0,0 +1,26 @@ +package ie.oshiro.messagepack.practice; +import java.io.IOException; +import java.util.LinkedList; +import java.util.List; + +import org.msgpack.MessagePack; +import org.msgpack.template.ListTemplate; +import org.msgpack.template.ValueTemplate; +import org.msgpack.type.Value; + +public class MSGListTest { + + public static void main(String[] args) throws IOException { + MessagePack msgpack = new MessagePack(); + List<Integer> writeList = new LinkedList<Integer>(); + writeList.add(1); + writeList.add(2); + writeList.add(3); + byte[] bytes; + bytes = msgpack.write(writeList); + msgpack.register(List.class, new ListTemplate(ValueTemplate.getInstance())); + for(Value v: (List<Value>) msgpack.read(bytes, List.class)) { + System.out.println(v.asIntegerValue()); + } + } +}