annotate src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/logger/LoggingChildren.java @ 103:bed3afd5c2e2

add Index but Not use
author one
date Fri, 12 Sep 2014 14:37:09 +0900
parents 14ce7a0dedca
children 74723b26ad96
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
92
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
1 package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger;
21
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
2
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
3 import java.util.Iterator;
92
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
4
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
5 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Children;
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
6 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
21
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
7 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.AppendChildAtOperation;
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DeleteChildAtOperation;
51
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 50
diff changeset
9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation;
23
Shoshi TAMAKI
parents: 21
diff changeset
10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither;
Shoshi TAMAKI
parents: 21
diff changeset
11 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either;
25
Shoshi TAMAKI
parents: 23
diff changeset
12 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error;
103
bed3afd5c2e2 add Index but Not use
one
parents: 92
diff changeset
13 import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.Logging;
21
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
14
92
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
15 public class LoggingChildren //implements EditableChildren
21
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
16 {
92
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
17 private final TreeNode wrap;
51
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 50
diff changeset
18 private final OperationLog log;
21
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
19
92
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
20 public LoggingChildren(TreeNode _wrap,OperationLog _log)
21
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
21 {
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
22 wrap = _wrap;
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
23 log = _log;
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
24 }
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
25
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
26 public int size()
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
27 {
92
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
28 Children children = wrap.getChildren();
51
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 50
diff changeset
29 return children.size();
21
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
30 }
35
Shoshi TAMAKI
parents: 31
diff changeset
31
92
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
32 /*
35
Shoshi TAMAKI
parents: 31
diff changeset
33 @Override
92
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
34 public Iterator<LoggingNode> iterator()
35
Shoshi TAMAKI
parents: 31
diff changeset
35 {
92
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
36 LoggingChildren children = wrap.getChildren();
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
37 return children.iterator();
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
38 }*/
36
Shoshi TAMAKI
parents: 35
diff changeset
39
103
bed3afd5c2e2 add Index but Not use
one
parents: 92
diff changeset
40 public Either<Error,Logging> edit(NodeOperation _op)
51
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 50
diff changeset
41 {
92
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
42 Either<Error,TreeNode> either = _op.invoke(wrap);
51
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 50
diff changeset
43 if(either.isA()){
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 50
diff changeset
44 return DefaultEither.newA(either.a());
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 50
diff changeset
45 }
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 50
diff changeset
46
92
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
47 TreeNode newWrap = either.b();
51
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 50
diff changeset
48 OperationLog newLog = log.add(_op);
103
bed3afd5c2e2 add Index but Not use
one
parents: 92
diff changeset
49 Logging newLoggingNode = new LoggingNode(newWrap,newLog);
51
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 50
diff changeset
50 return DefaultEither.newB(newLoggingNode);
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 50
diff changeset
51 }
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 50
diff changeset
52
103
bed3afd5c2e2 add Index but Not use
one
parents: 92
diff changeset
53 public Either<Error,Logging> addNewChildAt(final int _pos)
21
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
54 {
51
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 50
diff changeset
55 NodeOperation addNewChildAt = new AppendChildAtOperation(_pos);
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 50
diff changeset
56 return edit(addNewChildAt);
21
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
57 }
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
58
103
bed3afd5c2e2 add Index but Not use
one
parents: 92
diff changeset
59 public Either<Error,Logging> deleteChildAt(final int _pos)
21
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
60 {
51
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 50
diff changeset
61 NodeOperation deleteChildAt = new DeleteChildAtOperation(_pos);
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 50
diff changeset
62 return edit(deleteChildAt);
37
35e327577b58 added transaction
Shoshi TAMAKI
parents: 36
diff changeset
63 }
41
ed6737db637a added tests
Shoshi TAMAKI
parents: 37
diff changeset
64
103
bed3afd5c2e2 add Index but Not use
one
parents: 92
diff changeset
65 public Either<Error,Logging> at(int _pos)
41
ed6737db637a added tests
Shoshi TAMAKI
parents: 37
diff changeset
66 {
92
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
67 Children children = wrap.getChildren();
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
68 Either<Error,TreeNode> either = children.at(_pos);
41
ed6737db637a added tests
Shoshi TAMAKI
parents: 37
diff changeset
69 if(either.isA()){
ed6737db637a added tests
Shoshi TAMAKI
parents: 37
diff changeset
70 return DefaultEither.newA(either.a());
ed6737db637a added tests
Shoshi TAMAKI
parents: 37
diff changeset
71 }
ed6737db637a added tests
Shoshi TAMAKI
parents: 37
diff changeset
72
92
14ce7a0dedca Logging Node and Editor
one
parents: 78
diff changeset
73 TreeNode node = either.b();
103
bed3afd5c2e2 add Index but Not use
one
parents: 92
diff changeset
74 Logging logNode = new LoggingNode(node);
bed3afd5c2e2 add Index but Not use
one
parents: 92
diff changeset
75 return DefaultEither.newB(logNode);
41
ed6737db637a added tests
Shoshi TAMAKI
parents: 37
diff changeset
76 }
21
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
77 }