KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > faces > model > SelectItem


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 package javax.faces.model;
17
18 import java.io.Serializable JavaDoc;
19
20 /**
21  * @author Thomas Spiegl (latest modification by $Author: mwessendorf $)
22  * @version $Revision: 1.7 $ $Date: 2004/07/01 22:01:10 $
23  * $Log: SelectItem.java,v $
24  * Revision 1.7 2004/07/01 22:01:10 mwessendorf
25  * ASF switch
26  *
27  * Revision 1.6 2004/04/07 08:15:41 manolito
28  * correct label handling
29  *
30  */

31 public class SelectItem implements Serializable JavaDoc
32 {
33     // FIELDS
34
private Object JavaDoc _value;
35     private String JavaDoc _label;
36     private String JavaDoc _description;
37     private boolean _disabled;
38
39     // CONSTRUCTORS
40
public SelectItem()
41     {
42     }
43
44     public SelectItem(Object JavaDoc value)
45     {
46         if (value == null) throw new NullPointerException JavaDoc("value");
47         _value = value;
48         _label = value.toString();
49         _description = null;
50         _disabled = false;
51     }
52
53     public SelectItem(Object JavaDoc value, String JavaDoc label)
54     {
55         if (value == null) throw new NullPointerException JavaDoc("value");
56         if (label == null) throw new NullPointerException JavaDoc("label");
57         _value = value;
58         _label = label;
59         _description = null;
60         _disabled = false;
61     }
62
63     public SelectItem(Object JavaDoc value, String JavaDoc label, String JavaDoc description)
64     {
65         if (value == null) throw new NullPointerException JavaDoc("value");
66         if (label == null) throw new NullPointerException JavaDoc("label");
67         _value = value;
68         _label = label;
69         _description = description;
70         _disabled = false;
71     }
72
73     public SelectItem(Object JavaDoc value, String JavaDoc label, String JavaDoc description, boolean disabled)
74     {
75         if (value == null) throw new NullPointerException JavaDoc("value");
76         if (label == null) throw new NullPointerException JavaDoc("label");
77         _value = value;
78         _label = label;
79         _description = description;
80         _disabled = disabled;
81     }
82
83     // METHODS
84
public String JavaDoc getDescription()
85     {
86         return _description;
87     }
88
89     public void setDescription(String JavaDoc description)
90     {
91         _description = description;
92     }
93
94     public boolean isDisabled()
95     {
96         return _disabled;
97     }
98
99     public void setDisabled(boolean disabled)
100     {
101         _disabled = disabled;
102     }
103
104     public String JavaDoc getLabel()
105     {
106         return _label;
107     }
108
109     public void setLabel(String JavaDoc label)
110     {
111         if (label == null) throw new NullPointerException JavaDoc("label");
112         _label = label;
113     }
114
115     public Object JavaDoc getValue()
116     {
117         return _value;
118     }
119
120     public void setValue(Object JavaDoc value)
121     {
122         if (value == null) throw new NullPointerException JavaDoc("value");
123         _value = value;
124     }
125 }
126
Popular Tags