0
|
1 package jp.ac.u_ryukyu.ie.cr.jungle.store.trasnformer;
|
|
2
|
|
3 import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.TreeNode;
|
|
4 import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.logger.LoggingNode;
|
|
5 import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.logger.OperationLog;
|
|
6 import jp.ac.u_ryukyu.ie.cr.jungle.util.DefaultEither;
|
|
7 import jp.ac.u_ryukyu.ie.cr.jungle.util.Either;
|
|
8 import jp.ac.u_ryukyu.ie.cr.jungle.util.Error;
|
|
9
|
|
10 public class AppendChildAt implements NodeEditor
|
|
11 {
|
|
12 private final int pos;
|
|
13
|
|
14 public AppendChildAt(int _pos)
|
|
15 {
|
|
16 pos = _pos;
|
|
17 }
|
|
18
|
|
19 public Either<Error, LoggingNode> _edit(LoggingNode _e)
|
|
20 {
|
|
21 Either<Error,LoggingNode> either = _e.getChildren().addNewChildAt(pos);
|
|
22 if(either.isA()){
|
|
23 // error
|
|
24 return either;
|
|
25 }
|
|
26 return DefaultEither.newB(either.b());
|
|
27 }
|
|
28
|
|
29 @Override
|
|
30 public Either<Error, LoggingNode> edit(TreeNode _e) {
|
|
31 LoggingNode logNode = wrap(_e);
|
|
32 return _edit(logNode);
|
|
33 }
|
|
34
|
|
35 public LoggingNode wrap(TreeNode node) {
|
|
36 return new LoggingNode(node);
|
|
37 }
|
|
38
|
|
39 @Override
|
|
40 public LoggingNode wrap(TreeNode node, OperationLog op) {
|
|
41 return new LoggingNode(node, op);
|
|
42 }
|
|
43
|
|
44 }
|