0
|
1 package treecms.proto.test;
|
|
2
|
|
3 import java.util.Iterator;
|
|
4
|
|
5 import treecms.proto.api.*;
|
|
6 import treecms.proto.simple.*;
|
|
7
|
20
|
8 public class SimpleNodeTest1
|
0
|
9 {
|
|
10 public static void main(String _arg[])
|
|
11 {
|
20
|
12 TreeBuilder builder = new SimpleTreeBuilder();
|
|
13 Node root = builder.getContents();
|
0
|
14 root.setTitle("root");
|
|
15
|
20
|
16 Node child1 = builder.createNode();
|
13
|
17 child1.setTitle("+-child1");
|
20
|
18 Node child2 = builder.createNode();
|
13
|
19 child2.setTitle("+-child2");
|
0
|
20
|
7
|
21 root.addChild(child1);
|
|
22 root.addChild(child2);
|
20
|
23
|
|
24 Node child11 = builder.createNode();
|
13
|
25 child11.setTitle(" +-child11");
|
20
|
26 Node child12 = builder.createNode();
|
13
|
27 child12.setTitle(" +-child12");
|
20
|
28 Node child13 = builder.createNode();
|
13
|
29 child13.setTitle(" +-child13");
|
0
|
30
|
7
|
31 child1.addChild(child11);
|
|
32 child1.addChild(child12);
|
|
33 child1.addChild(child13);
|
|
34
|
20
|
35 Node child21 = builder.createNode();
|
13
|
36 child21.setTitle(" +-child21");
|
0
|
37
|
7
|
38 child2.addChild(child21);
|
|
39
|
20
|
40 Node child211 = builder.createNode();
|
13
|
41 child211.setTitle(" +-child211");
|
20
|
42 Node child212 = builder.createNode();
|
13
|
43 child212.setTitle(" +-child212");
|
0
|
44
|
7
|
45 child21.addChild(child211);
|
|
46 child21.addChild(child212);
|
|
47
|
0
|
48
|
13
|
49 PreOrderTreeWalkerRecursive walker = new PreOrderTreeWalkerRecursive(root);
|
20
|
50 Iterator<Node> itr = walker.iterator();
|
0
|
51 while(itr.hasNext()){
|
20
|
52 Node node = itr.next();
|
26
|
53 System.out.println(node.getTitle()+"\t id:"+node.getID().toString());
|
0
|
54 }
|
|
55 }
|
|
56 }
|