74
|
1 package alice.jungle.operations;
|
|
2
|
|
3 import java.nio.ByteBuffer;
|
|
4
|
|
5 import org.msgpack.annotation.Message;
|
|
6
|
|
7 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command;
|
180
|
8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
|
74
|
9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation;
|
|
10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.PutAttribute;
|
|
11 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either;
|
|
12 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error;
|
190
|
13 import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.LoggingNode;
|
74
|
14 @Message
|
|
15 public class NetworkPutAttributeOperation implements NodeOperation
|
|
16 {
|
78
|
17
|
|
18 /* MessagePack cannot handle final.
|
|
19 *
|
74
|
20 * private final String key;
|
|
21 * private final ByteBuffer value;
|
|
22 */
|
109
|
23 public String key;
|
|
24 public ByteBuffer value;
|
74
|
25
|
|
26 public NetworkPutAttributeOperation()
|
|
27 {
|
|
28 key = null;
|
|
29 value = null;
|
|
30 }
|
|
31
|
|
32 public NetworkPutAttributeOperation(String _key,ByteBuffer _value)
|
|
33 {
|
|
34 key = _key;
|
|
35 value = _value;
|
|
36 }
|
|
37
|
|
38 @Override
|
|
39 public Command getCommand()
|
|
40 {
|
|
41 return Command.PUT_ATTRIBUTE;
|
|
42 }
|
|
43
|
180
|
44 @Override
|
|
45 public Either<Error, TreeNode> invoke(TreeNode _target)
|
74
|
46 {
|
180
|
47 return _target.getAttributes().put(key,value);
|
|
48 }
|
74
|
49
|
|
50 @Override
|
|
51 public int getPosition()
|
|
52 {
|
|
53 return -1;
|
|
54 }
|
|
55
|
|
56 @Override
|
|
57 public String getKey()
|
|
58 {
|
|
59 return key;
|
|
60 }
|
|
61
|
|
62 @Override
|
|
63 public ByteBuffer getValue()
|
|
64 {
|
|
65 return value;
|
|
66 }
|
|
67 }
|