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 {
|
|
16 /*
|
|
17 * private final String key;
|
|
18 * private final ByteBuffer value;
|
|
19 */
|
|
20 private String key;
|
|
21 private ByteBuffer value;
|
|
22
|
|
23 public NetworkPutAttributeOperation()
|
|
24 {
|
|
25 key = null;
|
|
26 value = null;
|
|
27 }
|
|
28
|
|
29 public NetworkPutAttributeOperation(String _key,ByteBuffer _value)
|
|
30 {
|
|
31 key = _key;
|
|
32 value = _value;
|
|
33 }
|
|
34
|
|
35 @Override
|
|
36 public Command getCommand()
|
|
37 {
|
|
38 return Command.PUT_ATTRIBUTE;
|
|
39 }
|
|
40
|
|
41 @Override
|
|
42 public <T extends EditableNode<T>> Either<Error, T> invoke(T _target)
|
|
43 {
|
|
44 PutAttribute putAttribute = new PutAttribute(key,value);
|
|
45 return putAttribute.edit(_target);
|
|
46 }
|
|
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 }
|