Mercurial > hg > Members > nobuyasu > jungle-network
view src/alice/jungle/operations/NetworkTreeOperation.java @ 77:2dba7e1cf9fa
Added NetworknodeOperation and Test
author | one |
---|---|
date | Tue, 15 Oct 2013 16:01:11 +0900 |
parents | 9e3198bf9547 |
children | 5b9708d9febc |
line wrap: on
line source
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; @Message public class NetworkTreeOperation implements TreeOperation { public NetworkNodePath path; public NetworkNodeOperation operation; public NetworkTreeOperation() { path = null; operation = null; } 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 public NodePath getNodePath() { return path; } @Override public NodeOperation getNodeOperation() { 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; } }