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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
78
540a27dde42f Delete EnableNode and EnableNodeWrapper
one
parents: 51
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.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
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
5 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation;
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
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
Shoshi TAMAKI
parents: 21
diff changeset
9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither;
Shoshi TAMAKI
parents: 21
diff changeset
10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either;
25
Shoshi TAMAKI
parents: 23
diff changeset
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
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
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
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
15 private final T wrap;
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
16 private final OperationLog log;
21
848f73545c4d add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff changeset
17
51
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
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
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
27 EditableAttributes<T> attributes = wrap.getAttributes();
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
28 return attributes.get(_key);
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
29 }
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
30
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
31 private Either<Error,LoggingNode<T>> edit(NodeOperation _op)
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
32 {
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
33 Either<Error,T> either = _op.invoke(wrap);
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
34 if(either.isA()){
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
35 return DefaultEither.newA(either.a());
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
36 }
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
37
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
38 T newWrap = either.b();
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
39 OperationLog newLog = log.add(_op);
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
40 LoggingNode<T> newLoggingNode = new LoggingNode<T>(newWrap,newLog);
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
41
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
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
Shoshi TAMAKI
parents: 21
diff changeset
48
51
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
49 DeleteAttributeOperation deleteAttribute = new DeleteAttributeOperation(_key);
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
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
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
56 PutAttributeOperation putAttribute = new PutAttributeOperation(_key,_value);
bc119c52d5cc modified LoggingNode package
Shoshi TAMAKI
parents: 37
diff changeset
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
540a27dde42f Delete EnableNode and EnableNodeWrapper
one
parents: 51
diff changeset
60 */