1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.struts2.dojo.views.jsp.ui;
23
24 import java.util.ArrayList;
25 import java.util.HashMap;
26 import java.util.List;
27 import java.util.Map;
28
29 /***
30 * Used by Tree Component Test. Copied from showcase.
31 */
32 public class Category {
33 private static Map<Long, Category> catMap = new HashMap<Long, Category>();
34
35 static {
36 new Category(1, "Root",
37 new Category(2, "Java",
38 new Category(3, "Web Frameworks",
39 new Category(4, "Struts"),
40 new Category(7, "Stripes"),
41 new Category(8, "Rife")),
42 new Category(9, "Persistence",
43 new Category(10, "iBatis"),
44 new Category(11, "Hibernate"),
45 new Category(12, "JDO"),
46 new Category(13, "JDBC"))),
47 new Category(14, "JavaScript",
48 new Category(15, "Dojo"),
49 new Category(16, "Prototype"),
50 new Category(17, "Scriptaculous"),
51 new Category(18, "OpenRico"),
52 new Category(19, "DWR")));
53 }
54
55 public static Category getById(long id) {
56 return catMap.get(id);
57 }
58
59 private long id;
60 private String name;
61 private List<Category> children;
62 private boolean toggle;
63
64 public Category(long id, String name, Category... children) {
65 this.id = id;
66 this.name = name;
67 this.children = new ArrayList<Category>();
68 for (Category child : children) {
69 this.children.add(child);
70 }
71
72 catMap.put(id, this);
73 }
74
75 public long getId() {
76 return id;
77 }
78
79 public void setId(long id) {
80 this.id = id;
81 }
82
83 public String getName() {
84 return name;
85 }
86
87 public void setName(String name) {
88 this.name = name;
89 }
90
91 public List<Category> getChildren() {
92 return children;
93 }
94
95 public void setChildren(List<Category> children) {
96 this.children = children;
97 }
98
99 public void toggle() {
100 toggle = !toggle;
101 }
102
103 public boolean isToggle() {
104 return toggle;
105 }
106 }