KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > util > HtmlItem


1 /*
2  * Copyright 2000-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 package org.apache.jetspeed.util;
17
18 import java.io.Serializable JavaDoc;
19
20 /**
21  * General <Name Value Selected> utility class, can be used to store info
22  * regarding checkboxes, dropdowns and other html items
23  *
24  * @author <a HREF="mailto:taylor@apache.org">David Sean Taylor</a>
25  * @version $Id: HtmlItem.java,v 1.3 2004/02/23 03:23:42 jford Exp $
26  */

27 public class HtmlItem implements Serializable JavaDoc
28 {
29
30     private int intValue = -1;
31     private String JavaDoc name;
32     private boolean selected = false;
33
34     private String JavaDoc value = null;
35
36     /**
37     * Default constructor
38     *
39     */

40     public HtmlItem()
41     {
42     }
43
44     /**
45     * Constructor that takes intValue and description.
46     * Don't have to call set methods if this is used.
47     *
48     * @param sValue The list item value
49     * @param sDescription The list item description
50     */

51     public HtmlItem(int sValue, String JavaDoc sDescription)
52     {
53       this.setIntValue(sValue);
54       this.setName(sDescription);
55     }
56
57     public HtmlItem(int sValue, String JavaDoc sDescription, boolean selected)
58     {
59       this.setIntValue(sValue);
60       this.setName(sDescription);
61       this.setSelected(selected);
62     }
63
64     public HtmlItem(String JavaDoc sValue, String JavaDoc sDescription)
65     {
66       this.setValue(sValue);
67       this.setName(sDescription);
68     }
69
70     public HtmlItem(String JavaDoc sValue, String JavaDoc sDescription, boolean selected)
71     {
72       this.setValue(sValue);
73       this.setName(sDescription);
74       this.setSelected(selected);
75     }
76
77     public HtmlItem(String JavaDoc sDescription)
78     {
79       this.setValue(sDescription);
80       this.setName(sDescription);
81     }
82
83     public HtmlItem(String JavaDoc sDescription, boolean selected)
84     {
85       this.setValue(sDescription);
86       this.setName(sDescription);
87       this.setSelected(selected);
88     }
89
90     /**
91     * Setter method
92     *
93     * @param sValue Item's value
94     */

95     private void setIntValue(int sValue)
96     {
97       intValue = sValue;
98     }
99
100     /**
101     * Setter method
102     *
103     * @param sValue Item's value
104     */

105     private void setValue(String JavaDoc sValue)
106     {
107       this.value = sValue;
108     }
109
110     /**
111     * Setter method
112     *
113     * @param sValue Item's description
114     */

115     private void setName(String JavaDoc sValue)
116     {
117       name = sValue;
118     }
119
120     public void setSelected(boolean value)
121     {
122       selected = value;
123     }
124     /**
125     * Accessor Method that returns the items value
126     *
127     * @return The Item's value
128     */

129     public int getIntValue()
130     {
131       return intValue;
132     }
133     /**
134     * Accessor Method that returns the items value
135     *
136     * @return The Item's value
137     */

138     public String JavaDoc getValue()
139     {
140       return value;
141     }
142
143     /**
144     * Accessor Method that returns the items description
145     *
146     * @return The Item's description
147     */

148     public String JavaDoc getName()
149     {
150       return name;
151     }
152
153     public boolean getSelected()
154     {
155       return selected;
156     }
157
158 }
159
160
Popular Tags