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
|
|
25 public NetworkTreeOperation(NodePath _p, NodeOperation _op) {
|
76
|
26 path = new NetworkNodePath(_p);
|
|
27 operation = new NetworkNodeOperation(_op);
|
|
28 }
|
|
29
|
|
30 public NetworkTreeOperation(NetworkNodePath _p, NodeOperation _op) {
|
|
31 path = _p;
|
|
32 operation = new NetworkNodeOperation(_op);
|
|
33 }
|
|
34
|
|
35 public NetworkTreeOperation(NetworkNodePath _p, NetworkNodeOperation _op) {
|
1
|
36 path = _p;
|
|
37 operation = _op;
|
|
38 }
|
77
|
39
|
|
40 @Override
|
1
|
41 public NodePath getNodePath() {
|
|
42 return path;
|
|
43 }
|
|
44
|
|
45 @Override
|
|
46 public NodeOperation getNodeOperation() {
|
76
|
47 Command c = operation.getCommand();
|
|
48 if (c == Command.PUT_ATTRIBUTE) {
|
|
49 return new PutAttributeOperation(operation.getKey(), operation.getValue());
|
|
50 } else if (c == Command.APPEND_CHILD) {
|
|
51 return new AppendChildAtOperation(operation.getPosition());
|
|
52 } else if (c == Command.DELETE_CHILD) {
|
|
53 return new DeleteChildAtOperation(operation.getPosition());
|
|
54 } else if (c == Command.DELETE_ATTRIBUTE){
|
|
55 return new DeleteAttributeOperation(operation.getKey());
|
|
56 }
|
|
57 return null;
|
1
|
58 }
|
|
59
|
|
60 }
|