# HG changeset patch # User one # Date 1381795998 -32400 # Node ID 2520a5bd3dac75e4bb78b2b1b086934f2dbb2e39 # Parent f1aef52c061181dc3684b9cc17ac1c4cf3178216 Added NetworkDeleteAttributeOperation and NetworkDeleteAttributeOperationTest diff -r f1aef52c0611 -r 2520a5bd3dac src/alice/jungle/operations/NetworkDeleteAttributeOperation.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/jungle/operations/NetworkDeleteAttributeOperation.java Tue Oct 15 09:13:18 2013 +0900 @@ -0,0 +1,60 @@ +package alice.jungle.operations; + +import java.nio.ByteBuffer; + +import org.msgpack.annotation.Message; + +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.DeleteAttribute; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableNode; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; + +@Message +public class NetworkDeleteAttributeOperation implements NodeOperation +{ + //private final String key; + private String key; + + public NetworkDeleteAttributeOperation() + { + key = null; + } + + public NetworkDeleteAttributeOperation(String _key) + { + key = _key; + } + + @Override + public Command getCommand() + { + return Command.DELETE_ATTRIBUTE; + } + + @Override + public > Either invoke(T _target) + { + DeleteAttribute deleteAttribute = new DeleteAttribute(key); + return deleteAttribute.edit(_target); + } + + @Override + public int getPosition() + { + return -1; + } + + @Override + public String getKey() + { + return key; + } + + @Override + public ByteBuffer getValue() + { + return null; + } +} diff -r f1aef52c0611 -r 2520a5bd3dac src/test/alice/jungle/core/operations/NetworkDeleteAttributeOprationTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/test/alice/jungle/core/operations/NetworkDeleteAttributeOprationTest.java Tue Oct 15 09:13:18 2013 +0900 @@ -0,0 +1,24 @@ +package test.alice.jungle.core.operations; + +import java.io.IOException; + +import org.msgpack.MessagePack; +import org.msgpack.type.Value; + +import alice.jungle.operations.NetworkDeleteAttributeOperation; +import junit.framework.TestCase; + +public class NetworkDeleteAttributeOprationTest extends TestCase { + + public void testMsgpackConvert() throws IOException { + NetworkDeleteAttributeOperation op = new NetworkDeleteAttributeOperation("hoge"); + MessagePack msgpack = new MessagePack(); + Value v = msgpack.unconvert(op); + NetworkDeleteAttributeOperation mOp = msgpack.convert(v, NetworkDeleteAttributeOperation.class); + assertEquals(op.getCommand(), mOp.getCommand()); + assertEquals(mOp.getKey(), "hoge"); + + } + + +}