13
|
1 package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer;
|
|
2
|
|
3 import java.nio.ByteBuffer;
|
|
4
|
78
|
5 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
|
|
6 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNodeAttributes;
|
79
|
7 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.DefaultOperationLog;
|
|
8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.OperationLog;
|
92
|
9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DeleteChildAtOperation;
|
|
10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation;
|
79
|
11 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.PutAttributeOperation;
|
92
|
12 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither;
|
23
|
13 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either;
|
24
|
14 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error;
|
23
|
15
|
24
|
16 public class PutAttribute implements NodeEditor
|
13
|
17 {
|
|
18 private final String key;
|
|
19 private final ByteBuffer value;
|
92
|
20 private OperationLog log;
|
13
|
21
|
24
|
22 public PutAttribute(String _key,ByteBuffer _value)
|
13
|
23 {
|
|
24 key = _key;
|
|
25 value = _value;
|
92
|
26 log = new DefaultOperationLog();
|
13
|
27 }
|
|
28
|
|
29 @Override
|
86
|
30 public Either<Error,TreeNode> edit(TreeNode _e)
|
13
|
31 {
|
92
|
32 NodeOperation putAttributeOperation = new PutAttributeOperation(key,value);
|
|
33 Either<Error,TreeNode> either = putAttributeOperation.invoke(_e);
|
|
34 if(either.isA()){
|
|
35 // error
|
|
36 return either;
|
|
37 }
|
|
38 log = log.add(putAttributeOperation);
|
|
39 return DefaultEither.newB(either.b());
|
13
|
40 }
|
79
|
41
|
|
42 @Override
|
|
43 public OperationLog getLog() {
|
92
|
44 return log;
|
79
|
45 }
|
13
|
46 }
|