comparison src/jungle/test/codesegment/log/practice/StartCodeSegment.java @ 14:6dc6b25021a3

move some files
author one
date Thu, 27 Jun 2013 21:04:33 +0900
parents src/jungle/test/codesegment/practice/StartCodeSegment.java@f3c0a65c3f12
children 190f6a3bdab2
comparison
equal deleted inserted replaced
13:f3c0a65c3f12 14:6dc6b25021a3
1 package jungle.test.codesegment.log.practice;
2
3 import java.io.IOException;
4 import java.nio.ByteBuffer;
5 import java.util.LinkedList;
6 import java.util.List;
7
8 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath;
9 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.DefaultTreeOperationLog;
10 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.AppendChildAtOperation;
11 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DefaultTreeOperation;
12 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DeleteAttributeOperation;
13 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DeleteChildAtOperation;
14 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.PutAttributeOperation;
15 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation;
16 import jungle.test.datasegment.store.operations.DefaultTreeOperationLogContainer;
17 import alice.codesegment.CodeSegment;
18
19 public class StartCodeSegment extends CodeSegment {
20
21 @Override
22 public void run() {
23 System.out.println("run StartCodeSegment");
24
25 TestCodeSegment cs = new TestCodeSegment();
26 cs.arg1.setKey("log");
27 System.out.println("create TestCodeSegment");
28
29 DefaultTreeOperationLog log = getSampleOperationLog();
30 DefaultTreeOperationLogContainer logContainer = new DefaultTreeOperationLogContainer();
31 try {
32 logContainer.unconvert(log);
33 ods.update("local", "log", logContainer);
34 } catch (IOException e) {
35 e.printStackTrace();
36 }
37 }
38
39 public DefaultTreeOperationLog getSampleOperationLog() {
40 String key = "hoge";
41 ByteBuffer b = ByteBuffer.wrap("messagepack value".getBytes());
42 DefaultNodePath nodePath1 = new DefaultNodePath();
43 nodePath1 = nodePath1.add(1);
44 DefaultNodePath nodePath2 = nodePath1.add(2);
45 AppendChildAtOperation appendChildOp1 = new AppendChildAtOperation(1);
46 AppendChildAtOperation appendChildOp2 = new AppendChildAtOperation(2);
47 PutAttributeOperation putOp = new PutAttributeOperation(key, b);
48 DeleteAttributeOperation deleteOp = new DeleteAttributeOperation("hoge");
49 DeleteChildAtOperation deleteChild = new DeleteChildAtOperation(2);
50 List<TreeOperation> list = new LinkedList<TreeOperation>();
51 list.add(new DefaultTreeOperation(new DefaultNodePath(), appendChildOp1));
52 list.add(new DefaultTreeOperation(nodePath1, appendChildOp2));
53 list.add(new DefaultTreeOperation(nodePath2, putOp));
54 list.add(new DefaultTreeOperation(nodePath2, deleteOp));
55 list.add(new DefaultTreeOperation(nodePath1, deleteChild));
56 DefaultTreeOperationLog log = new DefaultTreeOperationLog(list, list.size());
57 return log;
58 }
59
60 }