Mercurial > hg > Members > tatsuki > bench > jungle-core
annotate src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/logger/LoggingAttributes.java @ 78:540a27dde42f
Delete EnableNode and EnableNodeWrapper
but not repair test program
author | one |
---|---|
date | Sun, 31 Aug 2014 00:44:35 +0900 |
parents | bc119c52d5cc |
children | 14ce7a0dedca |
rev | line source |
---|---|
78 | 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.nio.ByteBuffer; |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
4 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DeleteAttributeOperation; |
51 | 5 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation; |
6 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.PutAttributeOperation; | |
21
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
7 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableAttributes; |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.trasnformer.EditableNode; |
23 | 9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither; |
10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; | |
25 | 11 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; |
21
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
12 |
51 | 13 public class LoggingAttributes<T extends EditableNode<T>> implements EditableAttributes<LoggingNode<T>> |
21
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
14 { |
51 | 15 private final T wrap; |
16 private final OperationLog log; | |
21
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
17 |
51 | 18 public LoggingAttributes(T _wrap,OperationLog _log) |
21
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
19 { |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
20 wrap = _wrap; |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
21 log = _log; |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
22 } |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
23 |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
24 @Override |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
25 public ByteBuffer get(String _key) |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
26 { |
51 | 27 EditableAttributes<T> attributes = wrap.getAttributes(); |
28 return attributes.get(_key); | |
29 } | |
30 | |
31 private Either<Error,LoggingNode<T>> edit(NodeOperation _op) | |
32 { | |
33 Either<Error,T> either = _op.invoke(wrap); | |
34 if(either.isA()){ | |
35 return DefaultEither.newA(either.a()); | |
36 } | |
37 | |
38 T newWrap = either.b(); | |
39 OperationLog newLog = log.add(_op); | |
40 LoggingNode<T> newLoggingNode = new LoggingNode<T>(newWrap,newLog); | |
41 | |
42 return DefaultEither.newB(newLoggingNode); | |
21
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
43 } |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
44 |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
45 @Override |
31
418088ca2b30
added Generics parameters to EditableNode framework
Shoshi TAMAKI
parents:
25
diff
changeset
|
46 public Either<Error,LoggingNode<T>> delete(final String _key) |
21
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
47 { |
23 | 48 |
51 | 49 DeleteAttributeOperation deleteAttribute = new DeleteAttributeOperation(_key); |
50 return edit(deleteAttribute); | |
21
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
51 } |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
52 |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
53 @Override |
31
418088ca2b30
added Generics parameters to EditableNode framework
Shoshi TAMAKI
parents:
25
diff
changeset
|
54 public Either<Error,LoggingNode<T>> put(final String _key,final ByteBuffer _value) |
21
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
55 { |
51 | 56 PutAttributeOperation putAttribute = new PutAttributeOperation(_key,_value); |
57 return edit(putAttribute); | |
21
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
58 } |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
59 } |
78 | 60 */ |