1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5 *
6 * The contents of this file are subject to the terms of either the GNU
7 * General Public License Version 2 only ("GPL") or the Common Development
8 * and Distribution License("CDDL") (collectively, the "License"). You
9 * may not use this file except in compliance with the License. You can obtain
10 * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
11 * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
12 * language governing permissions and limitations under the License.
13 *
14 * When distributing the software, include this License Header Notice in each
15 * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
16 * Sun designates this particular file as subject to the "Classpath" exception
17 * as provided by Sun in the GPL Version 2 section of the License file that
18 * accompanied this code. If applicable, add the following below the License
19 * Header, with the fields enclosed by brackets [] replaced by your own
20 * identifying information: "Portions Copyrighted [year]
21 * [name of copyright owner]"
22 *
23 * Contributor(s):
24 *
25 * If you wish your version of this file to be governed by only the CDDL or
26 * only the GPL Version 2, indicate your decision by adding "[Contributor]
27 * elects to include this software in this distribution under the [CDDL or GPL
28 * Version 2] license." If you don't indicate a single choice of license, a
29 * recipient has the option to distribute your version of this file under
30 * either the CDDL, the GPL Version 2 or to extend the choice of license to
31 * its licensees as provided above. However, if you add GPL Version 2 code
32 * and therefore, elected the GPL Version 2 license, then the option applies
33 * only if the new code is made subject to such option by the copyright
34 * holder.
35 */
36 package javax.faces.component.html;
37
38 import java.io.IOException;
39 import java.util.List;
40 import java.util.ArrayList;
41 import java.util.Arrays;
42
43 import javax.faces.context.FacesContext;
44 import javax.el.MethodExpression;
45 import javax.el.ValueExpression;
46
47
48 /*
49 * ******* GENERATED CODE - DO NOT EDIT *******
50 */
51
52
53 /**
54 * <p>Renders the component value as text, optionally wrapping in a
55 * <code>span</code> element if I18N attributes, CSS styles or style
56 * classes are specified.</p>
57 * <p>By default, the <code>rendererType</code> property must be set to "<code>javax.faces.Text</code>".
58 * This value can be changed by calling the <code>setRendererType()</code> method.</p>
59 */
60 public class HtmlOutputText extends javax.faces.component.UIOutput {
61
62
63
64 private static final String[] OPTIMIZED_PACKAGES = {
65 "javax.faces.component",
66 "javax.faces.component.html"
67 };
68
69 public HtmlOutputText() {
70 super();
71 setRendererType("javax.faces.Text");
72 }
73
74
75 /**
76 * <p>The standard component type for this component.</p>
77 */
78 public static final String COMPONENT_TYPE = "javax.faces.HtmlOutputText";
79
80
81 private java.lang.String dir;
82 /**
83 * <p>Return the value of the <code>dir</code> property.</p>
84 * <p>Contents: Direction indication for text that does not inherit directionality.
85 * Valid values are "LTR" (left-to-right) and "RTL" (right-to-left).
86 */
87 public java.lang.String getDir() {
88 if (null != this.dir) {
89 return this.dir;
90 }
91 ValueExpression _ve = getValueExpression("dir");
92 if (_ve != null) {
93 return (java.lang.String) _ve.getValue(getFacesContext().getELContext());
94 } else {
95 return null;
96 }
97 }
98
99 /**
100 * <p>Set the value of the <code>dir</code> property.</p>
101 */
102 public void setDir(java.lang.String dir) {
103 this.dir = dir;
104 handleAttribute("dir", dir);
105 }
106
107
108 private java.lang.Boolean escape;
109 /**
110 * <p>Return the value of the <code>escape</code> property.</p>
111 * <p>Contents: Flag indicating that characters that are sensitive
112 * in HTML and XML markup must be escaped. This flag
113 * is set to "true" by default.
114 */
115 public boolean isEscape() {
116 if (null != this.escape) {
117 return this.escape;
118 }
119 ValueExpression _ve = getValueExpression("escape");
120 if (_ve != null) {
121 return (java.lang.Boolean) _ve.getValue(getFacesContext().getELContext());
122 } else {
123 return true;
124 }
125 }
126
127 /**
128 * <p>Set the value of the <code>escape</code> property.</p>
129 */
130 public void setEscape(boolean escape) {
131 this.escape = escape;
132 }
133
134
135 private java.lang.String lang;
136 /**
137 * <p>Return the value of the <code>lang</code> property.</p>
138 * <p>Contents: Code describing the language used in the generated markup
139 * for this component.
140 */
141 public java.lang.String getLang() {
142 if (null != this.lang) {
143 return this.lang;
144 }
145 ValueExpression _ve = getValueExpression("lang");
146 if (_ve != null) {
147 return (java.lang.String) _ve.getValue(getFacesContext().getELContext());
148 } else {
149 return null;
150 }
151 }
152
153 /**
154 * <p>Set the value of the <code>lang</code> property.</p>
155 */
156 public void setLang(java.lang.String lang) {
157 this.lang = lang;
158 handleAttribute("lang", lang);
159 }
160
161
162 private java.lang.String style;
163 /**
164 * <p>Return the value of the <code>style</code> property.</p>
165 * <p>Contents: CSS style(s) to be applied when this component is rendered.
166 */
167 public java.lang.String getStyle() {
168 if (null != this.style) {
169 return this.style;
170 }
171 ValueExpression _ve = getValueExpression("style");
172 if (_ve != null) {
173 return (java.lang.String) _ve.getValue(getFacesContext().getELContext());
174 } else {
175 return null;
176 }
177 }
178
179 /**
180 * <p>Set the value of the <code>style</code> property.</p>
181 */
182 public void setStyle(java.lang.String style) {
183 this.style = style;
184 handleAttribute("style", style);
185 }
186
187
188 private java.lang.String styleClass;
189 /**
190 * <p>Return the value of the <code>styleClass</code> property.</p>
191 * <p>Contents: Space-separated list of CSS style class(es) to be applied when
192 * this element is rendered. This value must be passed through
193 * as the "class" attribute on generated markup.
194 */
195 public java.lang.String getStyleClass() {
196 if (null != this.styleClass) {
197 return this.styleClass;
198 }
199 ValueExpression _ve = getValueExpression("styleClass");
200 if (_ve != null) {
201 return (java.lang.String) _ve.getValue(getFacesContext().getELContext());
202 } else {
203 return null;
204 }
205 }
206
207 /**
208 * <p>Set the value of the <code>styleClass</code> property.</p>
209 */
210 public void setStyleClass(java.lang.String styleClass) {
211 this.styleClass = styleClass;
212 }
213
214
215 private java.lang.String title;
216 /**
217 * <p>Return the value of the <code>title</code> property.</p>
218 * <p>Contents: Advisory title information about markup elements generated
219 * for this component.
220 */
221 public java.lang.String getTitle() {
222 if (null != this.title) {
223 return this.title;
224 }
225 ValueExpression _ve = getValueExpression("title");
226 if (_ve != null) {
227 return (java.lang.String) _ve.getValue(getFacesContext().getELContext());
228 } else {
229 return null;
230 }
231 }
232
233 /**
234 * <p>Set the value of the <code>title</code> property.</p>
235 */
236 public void setTitle(java.lang.String title) {
237 this.title = title;
238 handleAttribute("title", title);
239 }
240
241
242 private Object[] _values;
243
244 public Object saveState(FacesContext _context) {
245 if (_values == null) {
246 _values = new Object[7];
247 }
248 _values[0] = super.saveState(_context);
249 _values[1] = dir;
250 _values[2] = escape;
251 _values[3] = lang;
252 _values[4] = style;
253 _values[5] = styleClass;
254 _values[6] = title;
255 return _values;
256 }
257
258
259 public void restoreState(FacesContext _context, Object _state) {
260 _values = (Object[]) _state;
261 super.restoreState(_context, _values[0]);
262 this.dir = (java.lang.String) _values[1];
263 this.escape = (java.lang.Boolean) _values[2];
264 this.lang = (java.lang.String) _values[3];
265 this.style = (java.lang.String) _values[4];
266 this.styleClass = (java.lang.String) _values[5];
267 this.title = (java.lang.String) _values[6];
268 }
269
270
271 private void handleAttribute(String name, Object value) {
272 List<String> setAttributes = null;
273 String pkg = this.getClass().getPackage().getName();
274 if (Arrays.binarySearch(OPTIMIZED_PACKAGES, pkg) >= 0) {
275 setAttributes = (List<String>) this.getAttributes().get("javax.faces.component.UIComponentBase.attributesThatAreSet");
276 if (setAttributes == null) {
277 setAttributes = new ArrayList<String>(6);
278 this.getAttributes().put("javax.faces.component.UIComponentBase.attributesThatAreSet", setAttributes);
279 }
280 if (value == null) {
281 setAttributes.remove(name);
282 } else if (!setAttributes.contains(name)) {
283 setAttributes.add(name);
284 }
285 }
286 }
287
288 }