01: /*
02: * $Id: Category.java 471756 2006-11-06 15:01:43Z husted $
03: *
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
20: */
21: package org.apache.struts2.views.jsp.ui;
22:
23: import java.util.ArrayList;
24: import java.util.HashMap;
25: import java.util.List;
26: import java.util.Map;
27:
28: /**
29: * Used by Tree Component Test. Copied from showcase.
30: */
31: public class Category {
32: private static Map<Long, Category> catMap = new HashMap<Long, Category>();
33:
34: static {
35: new Category(1, "Root", new Category(2, "Java", new Category(3,
36: "Web Frameworks", new Category(4, "Struts"),
37: new Category(7, "Stripes"), new Category(8, "Rife")),
38: new Category(9, "Persistence", new Category(10,
39: "iBatis"), new Category(11, "Hibernate"),
40: new Category(12, "JDO"), new Category(13,
41: "JDBC"))), new Category(14,
42: "JavaScript", new Category(15, "Dojo"), new Category(
43: 16, "Prototype"), new Category(17,
44: "Scriptaculous"), new Category(18, "OpenRico"),
45: new Category(19, "DWR")));
46: }
47:
48: public static Category getById(long id) {
49: return catMap.get(id);
50: }
51:
52: private long id;
53: private String name;
54: private List<Category> children;
55: private boolean toggle;
56:
57: public Category(long id, String name, Category... children) {
58: this .id = id;
59: this .name = name;
60: this .children = new ArrayList<Category>();
61: for (Category child : children) {
62: this .children.add(child);
63: }
64:
65: catMap.put(id, this );
66: }
67:
68: public long getId() {
69: return id;
70: }
71:
72: public void setId(long id) {
73: this .id = id;
74: }
75:
76: public String getName() {
77: return name;
78: }
79:
80: public void setName(String name) {
81: this .name = name;
82: }
83:
84: public List<Category> getChildren() {
85: return children;
86: }
87:
88: public void setChildren(List<Category> children) {
89: this .children = children;
90: }
91:
92: public void toggle() {
93: toggle = !toggle;
94: }
95:
96: public boolean isToggle() {
97: return toggle;
98: }
99: }
|