Mercurial > hg > Members > nobuyasu > jungle-network
comparison src/main/java/alice/jungle/operations/NetworkTreeOperationLog.java @ 105:f9e29a52efd3
Move some files
author | one |
---|---|
date | Tue, 26 Nov 2013 06:43:10 +0900 |
parents | src/alice/jungle/operations/NetworkTreeOperationLog.java@75cf01a430a6 |
children |
comparison
equal
deleted
inserted
replaced
104:03bf62bb699e | 105:f9e29a52efd3 |
---|---|
1 package alice.jungle.operations; | |
2 | |
3 import java.util.Date; | |
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 { | |
17 public LinkedList<NetworkTreeOperation> list; | |
18 public int size; | |
19 String uuid; | |
20 String treeName; | |
21 long timestamp; | |
22 | |
23 public NetworkTreeOperationLog() { | |
24 list = new LinkedList<NetworkTreeOperation>(); | |
25 size = 0; | |
26 treeName = ""; | |
27 timestamp = new Date().getTime(); | |
28 } | |
29 | |
30 public NetworkTreeOperationLog(String _uuid, String _treeName, Iterable<TreeOperation> _list) | |
31 { | |
32 this(_uuid, _treeName, _list, new Date().getTime()); | |
33 } | |
34 | |
35 public NetworkTreeOperationLog(String _uuid, String _treeName, Iterable<TreeOperation> _list, long _timestamp) | |
36 { | |
37 uuid = _uuid; | |
38 treeName = _treeName; | |
39 list = new LinkedList<NetworkTreeOperation>(); | |
40 timestamp = _timestamp; | |
41 for(TreeOperation op: _list) { | |
42 NetworkTreeOperation nOp = new NetworkTreeOperation(op); | |
43 list.add(nOp); | |
44 } | |
45 size = list.size(); | |
46 } | |
47 | |
48 public NetworkTreeOperationLog(Iterable<TreeOperation> _list) | |
49 { | |
50 this("", "", _list); | |
51 } | |
52 | |
53 | |
54 @Override | |
55 public Iterator<TreeOperation> iterator() { | |
56 LinkedList<TreeOperation> opList = new LinkedList<TreeOperation>(); | |
57 for(NetworkTreeOperation op : list) { | |
58 opList.add(op); | |
59 } | |
60 return opList.iterator(); | |
61 } | |
62 | |
63 @Override | |
64 public NetworkTreeOperationLog add(NodePath _p, NodeOperation _op) | |
65 { | |
66 NetworkTreeOperation op = new NetworkTreeOperation(_p, _op); | |
67 list.add(op); | |
68 return this; | |
69 } | |
70 | |
71 @Override | |
72 public NetworkTreeOperationLog append(TreeOperationLog _log) | |
73 { | |
74 for (TreeOperation o : _log) { | |
75 NetworkTreeOperation op = new NetworkTreeOperation(o); | |
76 list.add(op); | |
77 } | |
78 return this; | |
79 } | |
80 | |
81 @Override | |
82 public int length() | |
83 { | |
84 return size; | |
85 } | |
86 | |
87 public String getUUID() { | |
88 return uuid; | |
89 } | |
90 | |
91 public String getTreeName() { | |
92 return treeName; | |
93 } | |
94 | |
95 public long getTimeStamp() { | |
96 return timestamp; | |
97 } | |
98 | |
99 public void setTimeStamp(long _timestamp) { | |
100 timestamp = _timestamp; | |
101 } | |
102 | |
103 } |