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;
|
|
8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation;
|
|
9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableNode;
|
|
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;
|
|
13 @Message
|
|
14 public class NetworkPutAttributeOperation implements NodeOperation
|
|
15 {
|
76
|
16 /* MessagePack cannot handle final.*/
|
74
|
17 /*
|
|
18 * private final String key;
|
|
19 * private final ByteBuffer value;
|
|
20 */
|
|
21 private String key;
|
|
22 private ByteBuffer value;
|
|
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
|
|
42 @Override
|
|
43 public <T extends EditableNode<T>> Either<Error, T> invoke(T _target)
|
|
44 {
|
|
45 PutAttribute putAttribute = new PutAttribute(key,value);
|
|
46 return putAttribute.edit(_target);
|
|
47 }
|
|
48
|
|
49 @Override
|
|
50 public int getPosition()
|
|
51 {
|
|
52 return -1;
|
|
53 }
|
|
54
|
|
55 @Override
|
|
56 public String getKey()
|
|
57 {
|
|
58 return key;
|
|
59 }
|
|
60
|
|
61 @Override
|
|
62 public ByteBuffer getValue()
|
|
63 {
|
|
64 return value;
|
|
65 }
|
|
66 }
|