31
|
1 package alice.jungle.operations;
|
1
|
2
|
76
|
3 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command;
|
1
|
4 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath;
|
76
|
5 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.AppendChildAtOperation;
|
|
6 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DeleteAttributeOperation;
|
|
7 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DeleteChildAtOperation;
|
1
|
8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation;
|
76
|
9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.PutAttributeOperation;
|
1
|
10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation;
|
|
11
|
|
12 import org.msgpack.annotation.Message;
|
|
13
|
|
14 @Message
|
|
15 public class NetworkTreeOperation implements TreeOperation {
|
|
16
|
76
|
17 public NetworkNodePath path;
|
|
18 public NetworkNodeOperation operation;
|
1
|
19
|
|
20 public NetworkTreeOperation() {
|
|
21 path = null;
|
|
22 operation = null;
|
|
23 }
|
|
24
|
79
|
25 public NetworkTreeOperation(TreeOperation treeOp) {
|
|
26 path = new NetworkNodePath(treeOp.getNodePath());
|
|
27 operation = new NetworkNodeOperation(treeOp.getNodeOperation());
|
|
28 }
|
|
29
|
1
|
30 public NetworkTreeOperation(NodePath _p, NodeOperation _op) {
|
76
|
31 path = new NetworkNodePath(_p);
|
|
32 operation = new NetworkNodeOperation(_op);
|
|
33 }
|
|
34
|
|
35 public NetworkTreeOperation(NetworkNodePath _p, NodeOperation _op) {
|
|
36 path = _p;
|
|
37 operation = new NetworkNodeOperation(_op);
|
|
38 }
|
|
39
|
81
|
40 public NetworkTreeOperation(NodePath _p, NetworkNodeOperation _op) {
|
|
41 path = new NetworkNodePath(_p);
|
|
42 operation = _op;
|
|
43 }
|
|
44
|
76
|
45 public NetworkTreeOperation(NetworkNodePath _p, NetworkNodeOperation _op) {
|
1
|
46 path = _p;
|
|
47 operation = _op;
|
|
48 }
|
77
|
49
|
|
50 @Override
|
1
|
51 public NodePath getNodePath() {
|
|
52 return path;
|
|
53 }
|
|
54
|
|
55 @Override
|
|
56 public NodeOperation getNodeOperation() {
|
76
|
57 Command c = operation.getCommand();
|
79
|
58 switch(c) {
|
|
59 case PUT_ATTRIBUTE:
|
76
|
60 return new PutAttributeOperation(operation.getKey(), operation.getValue());
|
79
|
61 case APPEND_CHILD:
|
76
|
62 return new AppendChildAtOperation(operation.getPosition());
|
79
|
63 case DELETE_CHILD:
|
76
|
64 return new DeleteChildAtOperation(operation.getPosition());
|
79
|
65 case DELETE_ATTRIBUTE:
|
76
|
66 return new DeleteAttributeOperation(operation.getKey());
|
79
|
67 default:
|
|
68 break;
|
76
|
69 }
|
|
70 return null;
|
1
|
71 }
|
|
72
|
|
73 }
|