105
|
1 package alice.jungle.persistent;
|
31
|
2
|
17
|
3 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList;
|
|
4 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListReader;
|
|
5 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeListWriter;
|
|
6 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.Journal;
|
|
7 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.Result;
|
|
8
|
|
9 public class AliceJournal implements Journal {
|
|
10
|
|
11 private static final AliceChangeListWriter ALICE_WRITER = new AliceChangeListWriter();
|
|
12 private static final AliceChangeListReader ALICE_READER = new AliceChangeListReader();
|
|
13 @Override
|
|
14 public ChangeListReader getReader() {
|
|
15 return ALICE_READER;
|
|
16 }
|
|
17 @Override
|
|
18 public ChangeListWriter getWriter() {
|
|
19 return ALICE_WRITER;
|
|
20 }
|
|
21
|
|
22 private static class AliceChangeListWriter implements ChangeListWriter
|
|
23 {
|
|
24 @Override
|
|
25 public Result write(ChangeList _operations)
|
|
26 {
|
63
|
27 /*
|
17
|
28 for(TreeOperation op : _operations){
|
|
29 NodePath p = op.getNodePath();
|
|
30 NodeOperation nodeOp = op.getNodeOperation();
|
|
31 Command c = nodeOp.getCommand();
|
|
32 String args = "";
|
|
33 switch(c){
|
|
34 case PUT_ATTRIBUTE:
|
|
35 String key = nodeOp.getKey();
|
|
36 ByteBuffer value = nodeOp.getValue();
|
|
37 if(value.limit() < 100){
|
|
38 args = String.format("key:%s,value:%s",key,new String(value.array()));
|
|
39 }else{
|
|
40 args = String.format("key:%s,value:%d",key,value.limit());
|
|
41 }
|
|
42 break;
|
|
43 case DELETE_ATTRIBUTE:
|
|
44 args = String.format("key:%s",nodeOp.getKey());
|
|
45 break;
|
|
46 case APPEND_CHILD:
|
|
47 args = String.format("pos:%d",nodeOp.getPosition());
|
|
48 break;
|
|
49 case DELETE_CHILD:
|
|
50 args = String.format("pos:%d",nodeOp.getPosition());
|
|
51 break;
|
|
52 }
|
|
53 System.out.println(String.format("[%s:%s:%s]",c,p,args));
|
|
54 }
|
63
|
55 */
|
17
|
56 return Result.SUCCESS;
|
|
57 }
|
|
58 }
|
|
59
|
|
60 private static class AliceChangeListReader implements ChangeListReader
|
|
61 {
|
|
62 @Override
|
|
63 public ChangeListReader newReader()
|
|
64 {
|
|
65 return this;
|
|
66 }
|
|
67
|
|
68 @Override
|
|
69 public ChangeList read()
|
|
70 {
|
|
71 return null;
|
|
72 }
|
|
73 }
|
|
74
|
|
75
|
|
76 }
|