comparison src/alice/jungle/operations/NetworkTreeOperation.java @ 76:9e3198bf9547

Modified NetworkNodePath
author one
date Tue, 15 Oct 2013 15:53:36 +0900
parents 190f6a3bdab2
children 2dba7e1cf9fa
comparison
equal deleted inserted replaced
75:87ec5dd0dc27 76:9e3198bf9547
1 package alice.jungle.operations; 1 package alice.jungle.operations;
2 2
3 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command;
3 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; 4 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath;
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;
4 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation; 8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation;
9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.PutAttributeOperation;
5 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation; 10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation;
6 11
7 import org.msgpack.annotation.Message; 12 import org.msgpack.annotation.Message;
8 13
9 @Message 14 @Message
10 public class NetworkTreeOperation implements TreeOperation { 15 public class NetworkTreeOperation implements TreeOperation {
11 16
12 public NodePath path; 17 public NetworkNodePath path;
13 public NodeOperation operation; 18 public NetworkNodeOperation operation;
14 19
15 public NetworkTreeOperation() { 20 public NetworkTreeOperation() {
16 path = null; 21 path = null;
17 operation = null; 22 operation = null;
18 } 23 }
19 24
20 public NetworkTreeOperation(NodePath _p, NodeOperation _op) { 25 public NetworkTreeOperation(NodePath _p, NodeOperation _op) {
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) {
21 path = _p; 36 path = _p;
22 operation = _op; 37 operation = _op;
23 } 38 }
24 39 @Override
25 @Override
26 public NodePath getNodePath() { 40 public NodePath getNodePath() {
27 return path; 41 return path;
28 } 42 }
29 43
30 @Override 44 @Override
31 public NodeOperation getNodeOperation() { 45 public NodeOperation getNodeOperation() {
32 return operation; 46 Command c = operation.getCommand();
47 if (c == Command.PUT_ATTRIBUTE) {
48 return new PutAttributeOperation(operation.getKey(), operation.getValue());
49 } else if (c == Command.APPEND_CHILD) {
50 return new AppendChildAtOperation(operation.getPosition());
51 } else if (c == Command.DELETE_CHILD) {
52 return new DeleteChildAtOperation(operation.getPosition());
53 } else if (c == Command.DELETE_ATTRIBUTE){
54 return new DeleteAttributeOperation(operation.getKey());
55 }
56 return null;
33 } 57 }
34 58
35 } 59 }