Mercurial > hg > Members > tatsuki > bench > jungle-core
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 |
rev | line source |
---|---|
92 | 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 | 4 |
5 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Children; | |
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 | 9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation; |
23 | 10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither; |
11 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; | |
25 | 12 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; |
103 | 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 | 15 public class LoggingChildren //implements EditableChildren |
21
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
16 { |
92 | 17 private final TreeNode wrap; |
51 | 18 private final OperationLog log; |
21
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
19 |
92 | 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 | 28 Children children = wrap.getChildren(); |
51 | 29 return children.size(); |
21
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
30 } |
35 | 31 |
92 | 32 /* |
35 | 33 @Override |
92 | 34 public Iterator<LoggingNode> iterator() |
35 | 35 { |
92 | 36 LoggingChildren children = wrap.getChildren(); |
37 return children.iterator(); | |
38 }*/ | |
36 | 39 |
103 | 40 public Either<Error,Logging> edit(NodeOperation _op) |
51 | 41 { |
92 | 42 Either<Error,TreeNode> either = _op.invoke(wrap); |
51 | 43 if(either.isA()){ |
44 return DefaultEither.newA(either.a()); | |
45 } | |
46 | |
92 | 47 TreeNode newWrap = either.b(); |
51 | 48 OperationLog newLog = log.add(_op); |
103 | 49 Logging newLoggingNode = new LoggingNode(newWrap,newLog); |
51 | 50 return DefaultEither.newB(newLoggingNode); |
51 } | |
52 | |
103 | 53 public Either<Error,Logging> addNewChildAt(final int _pos) |
21
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
54 { |
51 | 55 NodeOperation addNewChildAt = new AppendChildAtOperation(_pos); |
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 | 59 public Either<Error,Logging> deleteChildAt(final int _pos) |
21
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
60 { |
51 | 61 NodeOperation deleteChildAt = new DeleteChildAtOperation(_pos); |
62 return edit(deleteChildAt); | |
37 | 63 } |
41 | 64 |
103 | 65 public Either<Error,Logging> at(int _pos) |
41 | 66 { |
92 | 67 Children children = wrap.getChildren(); |
68 Either<Error,TreeNode> either = children.at(_pos); | |
41 | 69 if(either.isA()){ |
70 return DefaultEither.newA(either.a()); | |
71 } | |
72 | |
92 | 73 TreeNode node = either.b(); |
103 | 74 Logging logNode = new LoggingNode(node); |
75 return DefaultEither.newB(logNode); | |
41 | 76 } |
21
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
77 } |