KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > tags > tree > TreeHtmlAttributeInfo


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

18 package org.apache.beehive.netui.tags.tree;
19
20 /**
21  * This structure is used to track the use of HTML attributes within a tree item.
22  */

23 public class TreeHtmlAttributeInfo implements java.io.Serializable JavaDoc
24 {
25     public static final int HTML_LOCATION_DIV = 0;
26     public static final int HTML_LOCATION_ICON = 1;
27     public static final int HTML_LOCATION_SELECTION_LINK = 2;
28     public static final int HTML_LOCATION_CNT = 3;
29
30     private static final int APPLY_TO_DESCENDENTS = 0x01;
31     private static final int ON_ICON = 0x02;
32     private static final int ON_SELECTION_LINK = 0x04;
33     private static final int ON_DIV = 0x08;
34
35     private String JavaDoc _attribute;
36     private String JavaDoc _value;
37     private int state;
38     private TreeElement _parent;
39
40     /**
41      * Default constructor for creating a TreeHtmlAttributeInfo.
42      */

43     public TreeHtmlAttributeInfo()
44     {
45     }
46
47     /**
48      * Construct a new TreeHtmlAttributeInfo with the specified parameters.
49      * @param attribute the name of the attribute.
50      * @param value sets HTML attribute value.
51      */

52     public TreeHtmlAttributeInfo( String JavaDoc attribute, String JavaDoc value )
53     {
54         setAttribute(attribute);
55         setValue(value);
56     }
57
58     /**
59      * Return the name of the attribute.
60      * @return the attribute name
61      */

62     public String JavaDoc getAttribute()
63     {
64         return _attribute;
65     }
66
67     /**
68      * Set the name of the attribute.
69      * @param attribute the name of the attribute.
70      */

71     public void setAttribute(String JavaDoc attribute)
72     {
73         _attribute = attribute;
74     }
75
76     /**
77      * Return the value of the attribute.
78      * @return the String value of the attribute.
79      */

80     public String JavaDoc getValue()
81     {
82         return _value;
83     }
84
85     /**
86      * Set the HTML attribute value.
87      * @param value the value of the HTML attribute.
88      */

89     public void setValue(String JavaDoc value)
90     {
91         _value = value;
92     }
93
94     /**
95      * Return the parent node of the HtmlAttributeInfo item.
96      * This is the node the HtmlAttributeInfo item is associated with.
97      * @return the TreeElement parent.
98      */

99     public TreeElement getParent()
100     {
101         return _parent;
102     }
103
104     /**
105      * Set the parent of the HtmlAttributeInfo item.
106      * This sets the node the HtmlAttributeInfo item will be associated with.
107      * @param parent the TreeElement parent.
108      */

109     public void setParent(TreeElement parent)
110     {
111         _parent = parent;
112     }
113
114     /**
115      * Gets whether the attribute is applied to descendants of the node.
116      * @return whether the attribute is applied to descendants of the node.
117      */

118     public boolean isApplyToDescendents()
119     {
120         return ((state & APPLY_TO_DESCENDENTS) != 0);
121     }
122
123     /**
124      * Sets whether the attribute is applied to descendant nodes of the parent node.
125      * @param applyToDescendents
126      */

127     public void setApplyToDescendents(boolean applyToDescendents)
128     {
129         if (applyToDescendents)
130             state = state | APPLY_TO_DESCENDENTS;
131         else
132             state = state & (-1 ^ APPLY_TO_DESCENDENTS);
133
134     }
135
136     /**
137      * Gets whether the HTML attribute is on the <div> tag of the node.
138      * @return whether the attribute is on the <div> tag of the node.
139      */

140     public boolean isOnDiv()
141     {
142         return ((state & ON_DIV) != 0);
143     }
144
145     /**
146      * Sets whether the HTML attribute is on the node item's <div> tag.
147      * @param onDiv whether the attribute is on the <div> tag of the node.
148      */

149     public void setOnDiv(boolean onDiv)
150     {
151         if (onDiv)
152             state = state | ON_DIV;
153         else
154             state = state & (-1 ^ ON_DIV);
155
156     }
157
158     /**
159      * Gets whether the HTML attribute is on the <img> tag for the icon of the node.
160      * @return whether the attribute is on the <img> tag of the node.
161      */

162     public boolean isOnIcon()
163     {
164         return ((state & ON_ICON) != 0);
165     }
166
167     /**
168      * Sets whether the HTML attribute is on the node item's <img> tag for the icon.
169      * @param onIcon whether the attribute is on the <img> tag of the node.
170      */

171     public void setOnIcon(boolean onIcon)
172     {
173         if (onIcon)
174             state = state | ON_ICON;
175         else
176             state = state & (-1 ^ ON_ICON);
177
178     }
179
180     /**
181      * Gets whether the HTML attribute is on the selection link of the node.
182      * @return whether the attribute is on the selection link of the node.
183      */

184     public boolean isOnSelectionLink()
185     {
186         return ((state & ON_SELECTION_LINK) != 0);
187     }
188
189     /**
190      * Sets whether the HTML attribute is on the node item's selection.
191      * @param onSelectionLink whether the attribute is on the selection link of the node.
192      */

193     public void setOnSelectionLink(boolean onSelectionLink)
194     {
195         if (onSelectionLink)
196             state = state | ON_SELECTION_LINK;
197         else
198             state = state & (-1 ^ ON_SELECTION_LINK);
199     }
200 }
201
Popular Tags