Mercurial > hg > Database > jungle-network
view src/jungle/test/operations/messagepack/PackOperationLog.java @ 2:20498c88a70d
add Container
author | one |
---|---|
date | Sun, 09 Jun 2013 13:53:16 +0900 |
parents | 8ee02d1a2b12 |
children | 190f6a3bdab2 |
line wrap: on
line source
package jungle.test.operations.messagepack; import java.io.IOException; import java.util.Iterator; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation; import jungle.test.operations.NetworkNodeOperation; import jungle.test.operations.NetworkNodePath; import jungle.test.operations.NetworkTreeOperationLog; import org.msgpack.MessagePack; import org.msgpack.type.Value; public class PackOperationLog { public static void main(String[] args) throws IOException { MessagePack msgpack = new MessagePack(); final NetworkTreeOperationLog n = new NetworkTreeOperationLog(); NetworkNodePath p = new NetworkNodePath(); p = p.add(1).add(2).add(3); System.out.println(p.toString()); NetworkTreeOperationLog n2 = n.add(p, new NetworkNodeOperation()); System.out.println("n.length() = "+n.length()); NetworkTreeOperationLog n3 = n2.append(new NetworkTreeOperationLog()); Value v = msgpack.unconvert(n2); final NetworkTreeOperationLog log = msgpack.convert(v, NetworkTreeOperationLog.class); System.out.println("nn.lenght() = " + log.length()); ChangeList list = new ChangeList(){ @Override public Iterator<TreeOperation> iterator(){ return log.iterator(); } }; for (TreeOperation op : list) { NodePath nPath = op.getNodePath(); NodeOperation nodeOp = op.getNodeOperation(); Command c = nodeOp.getCommand(); System.out.println(nPath.toString()); } } }