1
|
1 package jungle.test.operations.messagepack;
|
|
2
|
|
3 import java.io.IOException;
|
|
4 import java.util.Iterator;
|
|
5
|
|
6 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList;
|
|
7 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command;
|
|
8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath;
|
|
9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation;
|
|
10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation;
|
|
11
|
|
12 import org.msgpack.MessagePack;
|
|
13 import org.msgpack.type.Value;
|
|
14
|
70
|
15 import alice.jungle.operations.NetworkAppendChildAtOperation;
|
31
|
16 import alice.jungle.operations.NetworkNodePath;
|
|
17 import alice.jungle.operations.NetworkTreeOperationLog;
|
|
18
|
1
|
19 public class PackOperationLog {
|
|
20
|
|
21 public static void main(String[] args) throws IOException {
|
|
22 MessagePack msgpack = new MessagePack();
|
2
|
23 final NetworkTreeOperationLog n = new NetworkTreeOperationLog();
|
1
|
24 NetworkNodePath p = new NetworkNodePath();
|
|
25 p = p.add(1).add(2).add(3);
|
|
26 System.out.println(p.toString());
|
70
|
27 NetworkTreeOperationLog n2 = n.add(p, new NetworkAppendChildAtOperation(1));
|
1
|
28 System.out.println("n.length() = "+n.length());
|
|
29
|
2
|
30 Value v = msgpack.unconvert(n2);
|
1
|
31 final NetworkTreeOperationLog log = msgpack.convert(v, NetworkTreeOperationLog.class);
|
2
|
32
|
1
|
33 System.out.println("nn.lenght() = " + log.length());
|
|
34 ChangeList list = new ChangeList(){
|
|
35 @Override
|
|
36 public Iterator<TreeOperation> iterator(){
|
|
37 return log.iterator();
|
|
38 }
|
|
39 };
|
|
40 for (TreeOperation op : list) {
|
|
41 NodePath nPath = op.getNodePath();
|
|
42 NodeOperation nodeOp = op.getNodeOperation();
|
|
43 Command c = nodeOp.getCommand();
|
70
|
44 System.out.println("Command : "+ c.toString());
|
1
|
45 System.out.println(nPath.toString());
|
|
46 }
|
|
47 }
|
|
48
|
2
|
49
|
|
50
|
|
51
|
1
|
52 }
|