1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.jetspeed.util;
17
18 import java.io.Serializable;
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
28 {
29
30 private int intValue = -1;
31 private String name;
32 private boolean selected = false;
33
34 private String 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 sDescription)
52 {
53 this.setIntValue(sValue);
54 this.setName(sDescription);
55 }
56
57 public HtmlItem(int sValue, String sDescription, boolean selected)
58 {
59 this.setIntValue(sValue);
60 this.setName(sDescription);
61 this.setSelected(selected);
62 }
63
64 public HtmlItem(String sValue, String sDescription)
65 {
66 this.setValue(sValue);
67 this.setName(sDescription);
68 }
69
70 public HtmlItem(String sValue, String sDescription, boolean selected)
71 {
72 this.setValue(sValue);
73 this.setName(sDescription);
74 this.setSelected(selected);
75 }
76
77 public HtmlItem(String sDescription)
78 {
79 this.setValue(sDescription);
80 this.setName(sDescription);
81 }
82
83 public HtmlItem(String 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 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 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 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 getName()
149 {
150 return name;
151 }
152
153 public boolean getSelected()
154 {
155 return selected;
156 }
157
158 }
159