0
|
1 package jp.ac.u_ryukyu.ie.cr.jungle.store.operations;
|
|
2
|
|
3 import java.nio.ByteBuffer;
|
|
4
|
|
5 import jp.ac.u_ryukyu.ie.cr.jungle.util.Either;
|
|
6 import jp.ac.u_ryukyu.ie.cr.jungle.store.Command;
|
|
7 import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.TreeNode;
|
|
8 import jp.ac.u_ryukyu.ie.cr.jungle.util.Error;
|
|
9
|
|
10
|
|
11 public class PutAttributeOperation implements NodeOperation
|
|
12 {
|
|
13 private final String key;
|
|
14 private final ByteBuffer value;
|
|
15
|
|
16 public PutAttributeOperation(String _key,ByteBuffer _value)
|
|
17 {
|
|
18 key = _key;
|
|
19 value = _value;
|
|
20 }
|
|
21
|
|
22 @Override
|
|
23 public Command getCommand()
|
|
24 {
|
|
25 return Command.PUT_ATTRIBUTE;
|
|
26 }
|
|
27
|
|
28 @Override
|
|
29 public Either<Error,TreeNode> invoke(TreeNode _target)
|
|
30 {
|
|
31 return _target.getAttributes().put(key,value);
|
|
32 }
|
|
33 @Override
|
|
34 public int getPosition()
|
|
35 {
|
|
36 return -1;
|
|
37 }
|
|
38
|
|
39 @Override
|
|
40 public String getKey()
|
|
41 {
|
|
42 return key;
|
|
43 }
|
|
44
|
|
45 @Override
|
|
46 public ByteBuffer getValue()
|
|
47 {
|
|
48 return value;
|
|
49 }
|
|
50 } |