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: lu4242 $)
27   * @version $Revision: 684928 $ $Date: 2008-08-11 16:00:54 -0500 (Mon, 11 Aug 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      private boolean _escape;
38  
39      // CONSTRUCTORS
40      public SelectItem()
41      {
42      }
43  
44      public SelectItem(Object value)
45      {
46          _value = value;
47          _label = value == null ? null : value.toString();
48          _description = null;
49          _disabled = false;
50          _escape=true;
51      }
52  
53      public SelectItem(Object value, String label)
54      {
55          _value = value;
56          _label = label;
57          _description = null;
58          _disabled = false;
59          _escape = true;
60      }
61  
62      public SelectItem(Object value, String label, String description)
63      {
64          _value = value;
65          _label = label;
66          _description = description;
67          _disabled = false;
68          _escape = true;
69      }
70  
71      public SelectItem(Object value, String label, String description, boolean disabled)
72      {
73          _value = value;
74          _label = label;
75          _description = description;
76          _disabled = disabled;
77          _escape = true;
78      }
79  
80      public SelectItem(Object value, String label, String description, boolean disabled, boolean escape)
81      {
82          _value = value;
83          _label = label;
84          _description = description;
85          _disabled = disabled;
86          this._escape = escape;
87      }
88      
89      // METHODS
90      public String getDescription()
91      {
92          return _description;
93      }
94  
95      public void setDescription(String description)
96      {
97          _description = description;
98      }
99  
100     public boolean isDisabled()
101     {
102         return _disabled;
103     }
104 
105     public void setDisabled(boolean disabled)
106     {
107         _disabled = disabled;
108     }
109 
110     public String getLabel()
111     {
112         return _label;
113     }
114 
115     public void setLabel(String label)
116     {
117         if (label == null)
118           throw new NullPointerException("label");
119         _label = label;
120     }
121 
122     public Object getValue()
123     {
124         return _value;
125     }
126 
127     public void setValue(Object value)
128     {
129         _value = value;
130     }
131 
132     public boolean isEscape()
133     {
134         return _escape;
135     }
136 
137     public void setEscape(boolean escape)
138     {
139         this._escape = escape;
140     }
141     
142 }