Mercurial > hg > Members > tatsuki > bench > jungle-core
annotate src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/store/impl/logger/LoggingAttributes.java @ 25:1b448f9249ee
mark
author | Shoshi TAMAKI |
---|---|
date | Sun, 13 Jan 2013 20:52:19 +0900 |
parents | 3ef2a66a8c5d |
children | 418088ca2b30 |
rev | line source |
---|---|
21
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
1 package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger; |
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; |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
5 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.Operation; |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
6 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.SetAttributeOperation; |
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 |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
13 public class LoggingAttributes implements EditableAttributes |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
14 { |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
15 private final EditableAttributes wrap; |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
16 private final Logger log; |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
17 |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
18 public LoggingAttributes(EditableAttributes _wrap,Logger _log) |
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 { |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
27 return wrap.get(_key); |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
28 } |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
29 |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
30 @Override |
23 | 31 public Either<Error,EditableNode> delete(final String _key) |
21
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
32 { |
23 | 33 |
34 Either<Error,EditableNode> either = wrap.delete(_key); | |
35 if(either.isA()){ | |
36 return either; | |
37 } | |
38 | |
21
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
39 Operation opDelete = new DeleteAttributeOperation(){ |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
40 @Override |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
41 public String getKey(){ |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
42 return _key; |
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 |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
46 Logger newLog = log.add(opDelete); |
23 | 47 EditableNode newWrap = either.b(); |
48 EditableNode newLoggingNode = new LoggingNode(newWrap,newLog); | |
21
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
49 |
23 | 50 return DefaultEither.newB(newLoggingNode); |
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 |
23 | 54 public Either<Error,EditableNode> put(final String _key,final ByteBuffer _value) |
21
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
55 { |
23 | 56 Either<Error,EditableNode> either = wrap.put(_key,_value); |
57 if(either.isA()){ | |
58 return either; | |
59 } | |
60 | |
21
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
61 Operation opPut = new SetAttributeOperation(){ |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
62 @Override |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
63 public String getKey(){ |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
64 return _key; |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
65 } |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
66 |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
67 @Override |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
68 public ByteBuffer getValue(){ |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
69 return _value; |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
70 } |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
71 }; |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
72 |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
73 Logger newLog = log.add(opPut); |
23 | 74 EditableNode newLoggingNode = new LoggingNode(either.b(),newLog); |
21
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
75 |
23 | 76 return DefaultEither.newB(newLoggingNode); |
21
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
77 } |
848f73545c4d
add LoggingNode , LoggingAttributes , LoggingChildren , Logger
Shoshi TAMAKI
parents:
diff
changeset
|
78 } |