annotate src/treecms/proto/test/SimpleNodeTest1.java @ 26:9b91329e8a04

commit for zemi , doent move
author ShoshiTAMAKI
date Tue, 02 Nov 2010 18:44:21 +0900
parents e950264f82d3
children 45881237e777
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f815c7c1fb38 hg init
shoshi
parents:
diff changeset
1 package treecms.proto.test;
f815c7c1fb38 hg init
shoshi
parents:
diff changeset
2
f815c7c1fb38 hg init
shoshi
parents:
diff changeset
3 import java.util.Iterator;
f815c7c1fb38 hg init
shoshi
parents:
diff changeset
4
f815c7c1fb38 hg init
shoshi
parents:
diff changeset
5 import treecms.proto.api.*;
f815c7c1fb38 hg init
shoshi
parents:
diff changeset
6 import treecms.proto.simple.*;
f815c7c1fb38 hg init
shoshi
parents:
diff changeset
7
20
ShoshiTAMAKI
parents: 13
diff changeset
8 public class SimpleNodeTest1
0
f815c7c1fb38 hg init
shoshi
parents:
diff changeset
9 {
f815c7c1fb38 hg init
shoshi
parents:
diff changeset
10 public static void main(String _arg[])
f815c7c1fb38 hg init
shoshi
parents:
diff changeset
11 {
20
ShoshiTAMAKI
parents: 13
diff changeset
12 TreeBuilder builder = new SimpleTreeBuilder();
ShoshiTAMAKI
parents: 13
diff changeset
13 Node root = builder.getContents();
0
f815c7c1fb38 hg init
shoshi
parents:
diff changeset
14 root.setTitle("root");
f815c7c1fb38 hg init
shoshi
parents:
diff changeset
15
20
ShoshiTAMAKI
parents: 13
diff changeset
16 Node child1 = builder.createNode();
13
3bccd745f2e2 bug fix
shoshi
parents: 8
diff changeset
17 child1.setTitle("+-child1");
20
ShoshiTAMAKI
parents: 13
diff changeset
18 Node child2 = builder.createNode();
13
3bccd745f2e2 bug fix
shoshi
parents: 8
diff changeset
19 child2.setTitle("+-child2");
0
f815c7c1fb38 hg init
shoshi
parents:
diff changeset
20
7
shoshi
parents: 0
diff changeset
21 root.addChild(child1);
shoshi
parents: 0
diff changeset
22 root.addChild(child2);
20
ShoshiTAMAKI
parents: 13
diff changeset
23
ShoshiTAMAKI
parents: 13
diff changeset
24 Node child11 = builder.createNode();
13
3bccd745f2e2 bug fix
shoshi
parents: 8
diff changeset
25 child11.setTitle(" +-child11");
20
ShoshiTAMAKI
parents: 13
diff changeset
26 Node child12 = builder.createNode();
13
3bccd745f2e2 bug fix
shoshi
parents: 8
diff changeset
27 child12.setTitle(" +-child12");
20
ShoshiTAMAKI
parents: 13
diff changeset
28 Node child13 = builder.createNode();
13
3bccd745f2e2 bug fix
shoshi
parents: 8
diff changeset
29 child13.setTitle(" +-child13");
0
f815c7c1fb38 hg init
shoshi
parents:
diff changeset
30
7
shoshi
parents: 0
diff changeset
31 child1.addChild(child11);
shoshi
parents: 0
diff changeset
32 child1.addChild(child12);
shoshi
parents: 0
diff changeset
33 child1.addChild(child13);
shoshi
parents: 0
diff changeset
34
20
ShoshiTAMAKI
parents: 13
diff changeset
35 Node child21 = builder.createNode();
13
3bccd745f2e2 bug fix
shoshi
parents: 8
diff changeset
36 child21.setTitle(" +-child21");
0
f815c7c1fb38 hg init
shoshi
parents:
diff changeset
37
7
shoshi
parents: 0
diff changeset
38 child2.addChild(child21);
shoshi
parents: 0
diff changeset
39
20
ShoshiTAMAKI
parents: 13
diff changeset
40 Node child211 = builder.createNode();
13
3bccd745f2e2 bug fix
shoshi
parents: 8
diff changeset
41 child211.setTitle(" +-child211");
20
ShoshiTAMAKI
parents: 13
diff changeset
42 Node child212 = builder.createNode();
13
3bccd745f2e2 bug fix
shoshi
parents: 8
diff changeset
43 child212.setTitle(" +-child212");
0
f815c7c1fb38 hg init
shoshi
parents:
diff changeset
44
7
shoshi
parents: 0
diff changeset
45 child21.addChild(child211);
shoshi
parents: 0
diff changeset
46 child21.addChild(child212);
shoshi
parents: 0
diff changeset
47
0
f815c7c1fb38 hg init
shoshi
parents:
diff changeset
48
13
3bccd745f2e2 bug fix
shoshi
parents: 8
diff changeset
49 PreOrderTreeWalkerRecursive walker = new PreOrderTreeWalkerRecursive(root);
20
ShoshiTAMAKI
parents: 13
diff changeset
50 Iterator<Node> itr = walker.iterator();
0
f815c7c1fb38 hg init
shoshi
parents:
diff changeset
51 while(itr.hasNext()){
20
ShoshiTAMAKI
parents: 13
diff changeset
52 Node node = itr.next();
26
9b91329e8a04 commit for zemi , doent move
ShoshiTAMAKI
parents: 20
diff changeset
53 System.out.println(node.getTitle()+"\t id:"+node.getID().toString());
0
f815c7c1fb38 hg init
shoshi
parents:
diff changeset
54 }
f815c7c1fb38 hg init
shoshi
parents:
diff changeset
55 }
f815c7c1fb38 hg init
shoshi
parents:
diff changeset
56 }