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  public class SelectItem implements Serializable
27  {
28      private static final long serialVersionUID = 8841094741464512226L;
29      // FIELDS
30      private Object _value;
31      private String _label;
32      private String _description;
33      private boolean _disabled;
34      private boolean _escape;
35      private boolean _noSelectionOption;
36  
37      // CONSTRUCTORS
38      public SelectItem()
39      {
40          this(null);
41      }
42  
43      public SelectItem(Object value)
44      {
45          this(value, value == null ? null : value.toString());
46      }
47  
48      public SelectItem(Object value, String label)
49      {
50          this(value, label, null);
51      }
52  
53      public SelectItem(Object value, String label, String description)
54      {
55          this(value, label, description, false);
56      }
57  
58      public SelectItem(Object value, String label, String description, boolean disabled)
59      {
60          this(value, label, description, disabled, true);
61      }
62  
63      public SelectItem(Object value, String label, String description, boolean disabled, boolean escape)
64      {
65          this(value, label, description, disabled, escape, false);
66      }
67  
68      /**
69       * 
70       * @param value
71       * @param label
72       * @param description
73       * @param disabled
74       * @param escape
75       * @param noSelectionOption
76       * 
77       * @since 2.0
78       */
79      public SelectItem(Object value, String label, String description, boolean disabled, boolean escape,
80                        boolean noSelectionOption)
81      {
82          _value = value;
83          _label = label;
84          _description = description;
85          _disabled = disabled;
86          _escape = escape;
87          _noSelectionOption = noSelectionOption;
88      }
89  
90      // METHODS
91      public String getDescription()
92      {
93          return _description;
94      }
95  
96      public String getLabel()
97      {
98          return _label;
99      }
100 
101     public Object getValue()
102     {
103         return _value;
104     }
105 
106     public boolean isDisabled()
107     {
108         return _disabled;
109     }
110 
111     public boolean isEscape()
112     {
113         return _escape;
114     }
115 
116     /**
117      * 
118      * @return
119      * 
120      * @since 2.0
121      */
122     public boolean isNoSelectionOption()
123     {
124         return _noSelectionOption;
125     }
126 
127     public void setDescription(String description)
128     {
129         _description = description;
130     }
131 
132     public void setDisabled(boolean disabled)
133     {
134         _disabled = disabled;
135     }
136 
137     public void setEscape(boolean escape)
138     {
139         _escape = escape;
140     }
141 
142     public void setLabel(String label)
143     {
144         if (label == null)
145         {
146             throw new NullPointerException("label");
147         }
148         _label = label;
149     }
150 
151     /**
152      * 
153      * @param noSelectionOption
154      * 
155      * @since 2.0
156      */
157     public void setNoSelectionOption(boolean noSelectionOption)
158     {
159         _noSelectionOption = noSelectionOption;
160     }
161 
162     public void setValue(Object value)
163     {
164         _value = value;
165     }
166 
167 }