comparison src/jungle/test/codesegment/practice/TestPutAttributeCodeSegment.java @ 20:506388c02b4b

fix using edit method
author one
date Sun, 30 Jun 2013 04:11:23 +0900
parents 08e283ede7c9
children 2a378b94cc55
comparison
equal deleted inserted replaced
19:08e283ede7c9 20:506388c02b4b
41 System.out.println("type = " + arg1.type); 41 System.out.println("type = " + arg1.type);
42 System.out.println("index = " + arg1.index); 42 System.out.println("index = " + arg1.index);
43 System.out.println("data = " + arg1.getVal()); 43 System.out.println("data = " + arg1.getVal());
44 System.out.println(((Value)arg1.getVal()).getType()); 44 System.out.println(((Value)arg1.getVal()).getType());
45 45
46 if (arg1.index >= 10) {
47 System.exit(0);
48 }
49
50 DefaultTreeOperationContainer convertedOpContainer = arg1.asClass(DefaultTreeOperationContainer.class); 46 DefaultTreeOperationContainer convertedOpContainer = arg1.asClass(DefaultTreeOperationContainer.class);
51 TreeOperation convertedOp = null; 47 TreeOperation convertedOp = null;
52 try { 48 try {
53 convertedOp = convertedOpContainer.convert(); 49 convertedOp = convertedOpContainer.convert();
54 } catch (IOException e) { 50 } catch (IOException e) {
55 e.printStackTrace(); 51 e.printStackTrace();
56 } 52 }
57 Jungle jungle = new JungleManager().getJungle(); 53 Jungle jungle = new JungleManager().getJungle();
58 JungleTree tree = jungle.getTreeByName("tree"); 54 JungleTree tree = jungle.getTreeByName("tree");
59 NetworkDefaultJungleTreeEditor editor = (NetworkDefaultJungleTreeEditor) tree.getTreeEditor(); 55 // NetworkDefaultJungleTreeEditor editor = (NetworkDefaultJungleTreeEditor) tree.getTreeEditor();
60 edit(editor, convertedOp); 56 // edit(editor, convertedOp);
57 JungleTreeEditor editor = tree.getTreeEditor();
61 editor.success(); 58 editor.success();
62 59 if (arg1.index >= 10) {
63 TestPutAttributeCodeSegment cs = new TestPutAttributeCodeSegment(); 60 new ShowAttribute();
64 DefaultTreeOperation treeOp = cs.getSampleOperation("message"+arg1.index); 61 ods.update("local","show",1);
65 DefaultTreeOperationContainer treeOperationContainer = new DefaultTreeOperationContainer(); 62 } else {
66 try { 63 TestPutAttributeCodeSegment cs = new TestPutAttributeCodeSegment();
67 treeOperationContainer.unconvert(treeOp); 64 DefaultTreeOperation treeOp = cs.getSampleOperation("message"+arg1.index);
68 } catch (IOException e) { 65 DefaultTreeOperationContainer treeOperationContainer = new DefaultTreeOperationContainer();
69 e.printStackTrace(); 66 try {
70 } 67 treeOperationContainer.unconvert(treeOp);
71 cs.ods.update("local", "log", treeOperationContainer); 68 } catch (IOException e) {
72 69 e.printStackTrace();
70 }
71 ods.update("local", "log", treeOperationContainer);
72 }
73 } 73 }
74 74
75 public DefaultTreeOperation getSampleOperation(String message) { 75 public DefaultTreeOperation getSampleOperation(String message) {
76 /* Create TreeOperation */ 76 /* Create TreeOperation */
77 String key = "hoge"; 77 String key = "key1";
78 ByteBuffer b = ByteBuffer.wrap(message.getBytes()); 78 ByteBuffer b = ByteBuffer.wrap(message.getBytes());
79 PutAttributeOperation op = new PutAttributeOperation(key, b); 79 PutAttributeOperation op = new PutAttributeOperation(key, b);
80 DefaultNodePath p = new DefaultNodePath(); 80 DefaultNodePath p = new DefaultNodePath();
81 p = p.add(0); 81 p = p.add(0);
82 DefaultTreeOperation treeOp = new DefaultTreeOperation(p, op); 82 DefaultTreeOperation treeOp = new DefaultTreeOperation(p, op);