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