31
|
1 package alice.jungle.operations;
|
1
|
2
|
93
|
3 import java.util.Date;
|
1
|
4 import java.util.Iterator;
|
|
5 import java.util.LinkedList;
|
|
6
|
|
7 import org.msgpack.annotation.Message;
|
|
8
|
|
9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath;
|
|
10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.TreeOperationLog;
|
|
11 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation;
|
|
12 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation;
|
|
13
|
|
14 @Message
|
|
15 public class NetworkTreeOperationLog implements TreeOperationLog
|
|
16 {
|
83
|
17 public LinkedList<NetworkTreeOperation> list;
|
2
|
18 public int size;
|
86
|
19 String uuid;
|
84
|
20 String treeName;
|
93
|
21 long timestamp;
|
1
|
22
|
|
23 public NetworkTreeOperationLog() {
|
83
|
24 list = new LinkedList<NetworkTreeOperation>();
|
1
|
25 size = 0;
|
84
|
26 treeName = "";
|
93
|
27 timestamp = new Date().getTime();
|
84
|
28 }
|
|
29
|
86
|
30 public NetworkTreeOperationLog(String _uuid, String _treeName, Iterable<TreeOperation> _list)
|
84
|
31 {
|
93
|
32 this(_uuid, _treeName, _list, new Date().getTime());
|
|
33 }
|
|
34
|
|
35 public NetworkTreeOperationLog(String _uuid, String _treeName, Iterable<TreeOperation> _list, long _timestamp)
|
|
36 {
|
86
|
37 uuid = _uuid;
|
84
|
38 treeName = _treeName;
|
|
39 list = new LinkedList<NetworkTreeOperation>();
|
93
|
40 timestamp = _timestamp;
|
84
|
41 for(TreeOperation op: _list) {
|
|
42 NetworkTreeOperation nOp = new NetworkTreeOperation(op);
|
|
43 list.add(nOp);
|
|
44 }
|
|
45 size = list.size();
|
1
|
46 }
|
83
|
47
|
|
48 public NetworkTreeOperationLog(Iterable<TreeOperation> _list)
|
|
49 {
|
93
|
50 this("", "", _list);
|
83
|
51 }
|
|
52
|
1
|
53
|
|
54 @Override
|
|
55 public Iterator<TreeOperation> iterator() {
|
83
|
56 LinkedList<TreeOperation> opList = new LinkedList<TreeOperation>();
|
|
57 for(NetworkTreeOperation op : list) {
|
|
58 opList.add(op);
|
|
59 }
|
|
60 return opList.iterator();
|
1
|
61 }
|
|
62
|
|
63 @Override
|
|
64 public NetworkTreeOperationLog add(NodePath _p, NodeOperation _op)
|
|
65 {
|
79
|
66 NetworkTreeOperation op = new NetworkTreeOperation(_p, _op);
|
|
67 list.add(op);
|
83
|
68 return this;
|
1
|
69 }
|
|
70
|
|
71 @Override
|
|
72 public NetworkTreeOperationLog append(TreeOperationLog _log)
|
|
73 {
|
79
|
74 for (TreeOperation o : _log) {
|
|
75 NetworkTreeOperation op = new NetworkTreeOperation(o);
|
|
76 list.add(op);
|
1
|
77 }
|
83
|
78 return this;
|
1
|
79 }
|
|
80
|
|
81 @Override
|
|
82 public int length()
|
|
83 {
|
|
84 return size;
|
|
85 }
|
84
|
86
|
86
|
87 public String getUUID() {
|
|
88 return uuid;
|
|
89 }
|
|
90
|
84
|
91 public String getTreeName() {
|
|
92 return treeName;
|
|
93 }
|
93
|
94
|
|
95 public long getTimeStamp() {
|
|
96 return timestamp;
|
|
97 }
|
|
98
|
|
99 public void setTimeStamp(long _timestamp) {
|
|
100 timestamp = _timestamp;
|
|
101 }
|
1
|
102
|
|
103 }
|