KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ajaxtags > helpers > TreeItem


1 /**
2  * Copyright 2005 Darren L. Spurgeon
3  * Copyright 2007 Jens Kapitza
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.ajaxtags.helpers;
18
19 import java.util.Map JavaDoc;
20
21 /**
22  * extend Item to easily have a tree item with more options
23  *
24  * @author Musachy Barroso
25  * @author Jens Kapitza
26  * @version $Revision: 1.7 $ $Date: 2007/07/22 18:04:50 $ $Author: jenskapitza $
27  */

28 public class TreeItem extends Item<String JavaDoc> {
29
30     /**
31      * key to set node or a leaf flag
32      */

33     static public final String JavaDoc LEAF = "leaf";
34     /**
35      * key to set collapsed flag
36      */

37     static public final String JavaDoc COLLAPSED = "collapsed";
38     /**
39      * key to set url flag
40      */

41     static public final String JavaDoc URL = "url";
42
43     /**
44      * check if this treeitem is a leaf or not
45      *
46      * @return true if this is a leaf else false
47      */

48     public boolean isLeaf() {
49         return Boolean.parseBoolean(getAttributeValue(LEAF));
50     }
51
52     /**
53      * Constructor for TreeItem
54      */

55     public TreeItem() {
56         super();
57     }
58
59     /**
60      * set node to leaf or not
61      *
62      * @param l
63      * true if it is leaf else false
64      */

65     public void setLeaf(boolean l) {
66         setAttributes(LEAF, String.valueOf(l));
67     }
68
69     /**
70      *
71      * @param name
72      * @param value
73      * @param asData
74      */

75     public TreeItem(String JavaDoc name, String JavaDoc value, boolean asData) {
76         this(name, value, false, null, asData);
77     }
78
79     /**
80      *
81      * @param name
82      * @param value
83      */

84     public TreeItem(String JavaDoc name, String JavaDoc value) {
85         this(name, value, false, null, false);
86     }
87
88     /**
89      * @param name
90      * @param value
91      * @param collapsed
92      * @param url
93      * @param asData
94      */

95     public TreeItem(String JavaDoc name, String JavaDoc value, boolean collapsed, String JavaDoc url,
96             boolean asData) {
97         this(name, value, asData, null);
98         setCollapsed(collapsed);
99         setUrl(url);
100     }
101
102     /**
103      * @param name
104      * @param value
105      * @param asData
106      * @param attributes
107      */

108     public TreeItem(String JavaDoc name, String JavaDoc value, boolean asData,
109             Map JavaDoc<String JavaDoc, String JavaDoc> attributes) {
110         super(name, value, asData);
111         setAllAttributes(attributes);
112     }
113
114     /**
115      * @return Returns the colapsed value
116      */

117     public boolean isCollapsed() {
118         return Boolean.parseBoolean(getAttributeValue(COLLAPSED));
119     }
120
121     /**
122      * @param collapsed
123      * The collapsed value to be set
124      */

125     public void setCollapsed(boolean collapsed) {
126         setAttributes(COLLAPSED, String.valueOf(collapsed));
127     }
128
129     /**
130      * @return Return the URL
131      */

132     public String JavaDoc getUrl() {
133         return getAttributeValue(URL);
134     }
135
136     /**
137      * @param url
138      * The url to be set
139      */

140     public void setUrl(String JavaDoc url) {
141         setAttributes(URL, url);
142     }
143
144 }
145
Popular Tags