View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package javax.faces.model;
20  
21  import java.io.Serializable;
22  
23  /**
24   * see Javadoc of <a href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/api/index.html">JSF Specification</a>
25   *
26   * @author Thomas Spiegl (latest modification by $Author: skitching $)
27   * @version $Revision: 676278 $ $Date: 2008-07-13 03:35:04 -0500 (Sun, 13 Jul 2008) $
28   */
29  public class SelectItem implements Serializable
30  {
31      private static final long serialVersionUID = 8841094741464512226L;
32      // FIELDS
33      private Object _value;
34      private String _label;
35      private String _description;
36      private boolean _disabled;
37  
38      // CONSTRUCTORS
39      public SelectItem()
40      {
41      }
42  
43      public SelectItem(Object value)
44      {
45          if (value == null) throw new NullPointerException("value");
46          _value = value;
47          _label = value.toString();
48          _description = null;
49          _disabled = false;
50      }
51  
52      public SelectItem(Object value, String label)
53      {
54          if (value == null) throw new NullPointerException("value");
55          if (label == null) throw new NullPointerException("label");
56          _value = value;
57          _label = label;
58          _description = null;
59          _disabled = false;
60      }
61  
62      public SelectItem(Object value, String label, String description)
63      {
64          if (value == null) throw new NullPointerException("value");
65          if (label == null) throw new NullPointerException("label");
66          _value = value;
67          _label = label;
68          _description = description;
69          _disabled = false;
70      }
71  
72      public SelectItem(Object value, String label, String description, boolean disabled)
73      {
74          if (value == null) throw new NullPointerException("value");
75          if (label == null) throw new NullPointerException("label");
76          _value = value;
77          _label = label;
78          _description = description;
79          _disabled = disabled;
80      }
81  
82      // METHODS
83      public String getDescription()
84      {
85          return _description;
86      }
87  
88      public void setDescription(String description)
89      {
90          _description = description;
91      }
92  
93      public boolean isDisabled()
94      {
95          return _disabled;
96      }
97  
98      public void setDisabled(boolean disabled)
99      {
100         _disabled = disabled;
101     }
102 
103     public String getLabel()
104     {
105         return _label;
106     }
107 
108     public void setLabel(String label)
109     {
110         if (label == null) throw new NullPointerException("label");
111         _label = label;
112     }
113 
114     public Object getValue()
115     {
116         return _value;
117     }
118 
119     public void setValue(Object value)
120     {
121         if (value == null) throw new NullPointerException("value");
122         _value = value;
123     }
124 }