Mercurial > hg > Members > nobuyasu > jungle-network
changeset 76:9e3198bf9547
Modified NetworkNodePath
author | one |
---|---|
date | Tue, 15 Oct 2013 15:53:36 +0900 |
parents | 87ec5dd0dc27 |
children | 2dba7e1cf9fa |
files | src/alice/jungle/operations/NetworkAppendChildAtOperation.java src/alice/jungle/operations/NetworkDeleteAttributeOperation.java src/alice/jungle/operations/NetworkDeleteChildAtOperation.java src/alice/jungle/operations/NetworkNodePath.java src/alice/jungle/operations/NetworkPutAttributeOperation.java src/alice/jungle/operations/NetworkTreeOperation.java |
diffstat | 6 files changed, 40 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/jungle/operations/NetworkAppendChildAtOperation.java Tue Oct 15 14:43:29 2013 +0900 +++ b/src/alice/jungle/operations/NetworkAppendChildAtOperation.java Tue Oct 15 15:53:36 2013 +0900 @@ -17,7 +17,7 @@ public class NetworkAppendChildAtOperation implements NodeOperation { // private final int pos; - /* MessagePack can not handle final.*/ + /* MessagePack cannot handle final.*/ private int pos; /* Position -1 represent root position. */
--- a/src/alice/jungle/operations/NetworkDeleteAttributeOperation.java Tue Oct 15 14:43:29 2013 +0900 +++ b/src/alice/jungle/operations/NetworkDeleteAttributeOperation.java Tue Oct 15 15:53:36 2013 +0900 @@ -14,6 +14,7 @@ @Message public class NetworkDeleteAttributeOperation implements NodeOperation { + /* MessagePack cannot handle final.*/ //private final String key; private String key;
--- a/src/alice/jungle/operations/NetworkDeleteChildAtOperation.java Tue Oct 15 14:43:29 2013 +0900 +++ b/src/alice/jungle/operations/NetworkDeleteChildAtOperation.java Tue Oct 15 15:53:36 2013 +0900 @@ -14,8 +14,8 @@ @Message public class NetworkDeleteChildAtOperation implements NodeOperation { + /* MessagePack cannot handle final.*/ //private final int pos; - /* MessagePack can not handle final.*/ private int pos;
--- a/src/alice/jungle/operations/NetworkNodePath.java Tue Oct 15 14:43:29 2013 +0900 +++ b/src/alice/jungle/operations/NetworkNodePath.java Tue Oct 15 15:53:36 2013 +0900 @@ -31,6 +31,13 @@ path = new LinkedList<Integer>(); } + public NetworkNodePath(NodePath _p) { + path = new LinkedList<Integer>(); + for(Integer pos: _p) { + path.add(pos); + } + } + private NetworkNodePath(LinkedList<Integer> _path) { path = _path; }
--- a/src/alice/jungle/operations/NetworkPutAttributeOperation.java Tue Oct 15 14:43:29 2013 +0900 +++ b/src/alice/jungle/operations/NetworkPutAttributeOperation.java Tue Oct 15 15:53:36 2013 +0900 @@ -13,6 +13,7 @@ @Message public class NetworkPutAttributeOperation implements NodeOperation { + /* MessagePack cannot handle final.*/ /* * private final String key; * private final ByteBuffer value;
--- a/src/alice/jungle/operations/NetworkTreeOperation.java Tue Oct 15 14:43:29 2013 +0900 +++ b/src/alice/jungle/operations/NetworkTreeOperation.java Tue Oct 15 15:53:36 2013 +0900 @@ -1,7 +1,12 @@ package alice.jungle.operations; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.AppendChildAtOperation; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DeleteAttributeOperation; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DeleteChildAtOperation; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.PutAttributeOperation; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation; import org.msgpack.annotation.Message; @@ -9,8 +14,8 @@ @Message public class NetworkTreeOperation implements TreeOperation { - public NodePath path; - public NodeOperation operation; + public NetworkNodePath path; + public NetworkNodeOperation operation; public NetworkTreeOperation() { path = null; @@ -18,18 +23,37 @@ } public NetworkTreeOperation(NodePath _p, NodeOperation _op) { + path = new NetworkNodePath(_p); + operation = new NetworkNodeOperation(_op); + } + + public NetworkTreeOperation(NetworkNodePath _p, NodeOperation _op) { + path = _p; + operation = new NetworkNodeOperation(_op); + } + + public NetworkTreeOperation(NetworkNodePath _p, NetworkNodeOperation _op) { path = _p; operation = _op; } - - @Override + @Override public NodePath getNodePath() { return path; } @Override public NodeOperation getNodeOperation() { - return operation; + Command c = operation.getCommand(); + if (c == Command.PUT_ATTRIBUTE) { + return new PutAttributeOperation(operation.getKey(), operation.getValue()); + } else if (c == Command.APPEND_CHILD) { + return new AppendChildAtOperation(operation.getPosition()); + } else if (c == Command.DELETE_CHILD) { + return new DeleteChildAtOperation(operation.getPosition()); + } else if (c == Command.DELETE_ATTRIBUTE){ + return new DeleteAttributeOperation(operation.getKey()); + } + return null; } }