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/javaee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
25   * 
26   * @author Thomas Spiegl (latest modification by $Author: bommel $)
27   * @version $Revision: 1187700 $ $Date: 2011-10-22 07:19:37 -0500 (Sat, 22 Oct 2011) $
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      private boolean _escape;
38      private boolean _noSelectionOption;
39  
40      // CONSTRUCTORS
41      public SelectItem()
42      {
43          this(null);
44      }
45  
46      public SelectItem(Object value)
47      {
48          this(value, value == null ? null : value.toString());
49      }
50  
51      public SelectItem(Object value, String label)
52      {
53          this(value, label, null);
54      }
55  
56      public SelectItem(Object value, String label, String description)
57      {
58          this(value, label, description, false);
59      }
60  
61      public SelectItem(Object value, String label, String description, boolean disabled)
62      {
63          this(value, label, description, disabled, true);
64      }
65  
66      public SelectItem(Object value, String label, String description, boolean disabled, boolean escape)
67      {
68          this(value, label, description, disabled, escape, false);
69      }
70  
71      /**
72       * 
73       * @param value
74       * @param label
75       * @param description
76       * @param disabled
77       * @param escape
78       * @param noSelectionOption
79       * 
80       * @since 2.0
81       */
82      public SelectItem(Object value, String label, String description, boolean disabled, boolean escape,
83                        boolean noSelectionOption)
84      {
85          _value = value;
86          _label = label;
87          _description = description;
88          _disabled = disabled;
89          _escape = escape;
90          _noSelectionOption = noSelectionOption;
91      }
92  
93      // METHODS
94      public String getDescription()
95      {
96          return _description;
97      }
98  
99      public String getLabel()
100     {
101         return _label;
102     }
103 
104     public Object getValue()
105     {
106         return _value;
107     }
108 
109     public boolean isDisabled()
110     {
111         return _disabled;
112     }
113 
114     public boolean isEscape()
115     {
116         return _escape;
117     }
118 
119     /**
120      * 
121      * @return
122      * 
123      * @since 2.0
124      */
125     public boolean isNoSelectionOption()
126     {
127         return _noSelectionOption;
128     }
129 
130     public void setDescription(String description)
131     {
132         _description = description;
133     }
134 
135     public void setDisabled(boolean disabled)
136     {
137         _disabled = disabled;
138     }
139 
140     public void setEscape(boolean escape)
141     {
142         _escape = escape;
143     }
144 
145     public void setLabel(String label)
146     {
147         if (label == null)
148             throw new NullPointerException("label");
149         _label = label;
150     }
151 
152     /**
153      * 
154      * @param noSelectionOption
155      * 
156      * @since 2.0
157      */
158     public void setNoSelectionOption(boolean noSelectionOption)
159     {
160         _noSelectionOption = noSelectionOption;
161     }
162 
163     public void setValue(Object value)
164     {
165         _value = value;
166     }
167 
168 }