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