KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > nextapp > echo2 > webrender > ClientProperties


1 /*
2  * This file is part of the Echo Web Application Framework (hereinafter "Echo").
3  * Copyright (C) 2002-2005 NextApp, Inc.
4  *
5  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6  *
7  * The contents of this file are subject to the Mozilla Public License Version
8  * 1.1 (the "License"); you may not use this file except in compliance with
9  * the License. You may obtain a copy of the License at
10  * http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * Alternatively, the contents of this file may be used under the terms of
18  * either the GNU General Public License Version 2 or later (the "GPL"), or
19  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
20  * in which case the provisions of the GPL or the LGPL are applicable instead
21  * of those above. If you wish to allow use of your version of this file only
22  * under the terms of either the GPL or the LGPL, and not to allow others to
23  * use your version of this file under the terms of the MPL, indicate your
24  * decision by deleting the provisions above and replace them with the notice
25  * and other provisions required by the GPL or the LGPL. If you do not delete
26  * the provisions above, a recipient may use your version of this file under
27  * the terms of any one of the MPL, the GPL or the LGPL.
28  */

29
30 package nextapp.echo2.webrender;
31
32 import java.io.Serializable JavaDoc;
33 import java.util.HashMap JavaDoc;
34 import java.util.Map JavaDoc;
35
36 /**
37  * A description of the client browser environment.
38  */

39 public class ClientProperties
40 implements Serializable JavaDoc {
41     
42     // General CSS Quirks describing specific out-of-spec behaviors particular to certain browsers.
43

44     /**
45      * A quirk flag indicating that CSS positioning values do not work correctly when either both
46      * "top" and "bottom" or "left" and "right" positions are set at the same time.
47      * <p>
48      * This quirk occurs with:
49      * <ul>
50      * <li>Internet Explorer 6 (Windows) [<em>Corrected in IE7 Beta 2 Refresh</em>]</li>
51      * </ul>
52      */

53     public static final String JavaDoc QUIRK_CSS_POSITIONING_ONE_SIDE_ONLY = "quirkCssPositioningOneSideOnly";
54     
55     /**
56      * A quirk flag indicating the only means of achieving 0 padding in table cells is to use 0px padding.
57      * <p>
58      * This quirk occurs with:
59      * <ul>
60      * <li>Internet Explorer 6 (Windows)</li>
61      * </ul>
62      */

63     public static final String JavaDoc QUIRK_CSS_BORDER_COLLAPSE_FOR_0_PADDING = "quirkCssBorderCollapseFor0Padding";
64     
65     /**
66      * A quirk flag indicating whether the client will incorrectly render CSS
67      * collapsed borders such that they reside entirely within the region
68      * of a component.
69      * <p>
70      * This quirk occurs with:
71      * <ul>
72      * <li>Internet Explorer 6 (Windows)</li>
73      * </ul>
74      * <p>
75      */

76     public static final String JavaDoc QUIRK_CSS_BORDER_COLLAPSE_INSIDE = "quirkCssBorderCollapseInside";
77     
78     /**
79      * A quirk flag indicating that the 'fixed' attribute should be used to
80      * for fixed-to-element background attachment.
81      * <p>
82      * This quirk occurs with:
83      * <ul>
84      * <li>Internet Explorer 6 (Windows) [<em>Corrected in IE7 Beta 2 Refresh</em>]</li>
85      * </ul>
86      */

87     public static final String JavaDoc QUIRK_CSS_BACKGROUND_ATTACHMENT_USE_FIXED = "quirkCssBackgroundAttachmentUseFixed";
88     
89     // Mozilla-specific Quirk Behaviors (behaviors that are more likely to be described as bugs)
90

91     /**
92      * A quirk flag indicating whether the client has poor performance when
93      * attempting to remove large element hierarchies from a DOM. This quirk can
94      * be alleviated by removing the hierarchy in smaller chunks.
95      * <p>
96      * This quirk occurs with:
97      * <ul>
98      * <li>Mozilla (all platforms)</li>
99      * <li>Mozilla Firefox ((all platforms)</li>
100      * </ul>
101      */

102     public static final String JavaDoc QUIRK_MOZILLA_PERFORMANCE_LARGE_DOM_REMOVE = "quirkMozillaPerformanceLargeDomRemove";
103
104     /**
105      * A quirk flag describing a Mozilla-specific behavior where the text
106      * contained within text input fields may be drawn outside of text
107      * input component due to the component having shifted its location
108      * on the page.
109      * <p>
110      * This quirk occurs with:
111      * <ul>
112      * <li>Mozilla (all platforms)</li>
113      * <li>Mozilla Firefox ((all platforms)</li>
114      * </ul>
115      */

116     public static final String JavaDoc QUIRK_MOZILLA_TEXT_INPUT_REPAINT = "quirkMozillaTextInputRepaint";
117     
118     /**
119      * A quirk flag describing an Opera-specific issue where the
120      * CSSStyleDeclaration.cssText property is unsupported.
121      * <p>
122      * This quirk occurs with:
123      * <ul>
124      * <li>Opera</li>
125      * </ul>
126      */

127     public static final String JavaDoc QUIRK_OPERA_NO_CSS_TEXT = "quirkOperaNoCssText";
128     
129     // Internet Explorer-specific Quirk Behaviors (behaviors that are more likely to be described as bugs)
130

131     /**
132      * A quirk flag describing the issue of "windowed" select fields in Internet Explorer, which do not
133      * render correctly with regard to z-index value.
134      * See http://support.microsoft.com/kb/q177378/ for an explanation of the underlying issue.
135      * <p>
136      * This quirk occurs with:
137      * <ul>
138      * <li>Internet Explorer 6 (Windows) [<em>Corrected in IE7 Beta 2 Refresh</em>]</li>
139      * </ul>
140      */

141     public static final String JavaDoc QUIRK_IE_SELECT_Z_INDEX = "quirkIESelectZIndex";
142     
143     /**
144      * A quirk flag describing a behavior where a specific "null" option be
145      * must be added to a drop-down-list-style SELECT element in order to to
146      * render a "no items selected" state.
147      * <p>
148      * This quirk occurs with:
149      * <ul>
150      * <li>Mozilla (all platforms)</li>
151      * <li>Mozilla Firefox ((all platforms)</li>
152      * </ul>
153      */

154     public static final String JavaDoc QUIRK_SELECT_REQUIRES_NULL_OPTION = "quirkSelectRequiresNullOption";
155     
156     /**
157      * A quirk flag describing various issues with rendering content in TEXTAREA elements.
158      * This quirk includes IE problems with "newline obliteration", and Opera8 problems with
159      * simply ignoring textarea content with importNode().
160      * <p>
161      * This quirk occurs with:
162      * <ul>
163      * <li>Internet Explorer 6 (Windows)</li>
164      * <li>Opera 8 (Linux and Windows Tested, assuming all))</li>
165      * </ul>
166      */

167     public static final String JavaDoc QUIRK_TEXTAREA_CONTENT = "quirkTextareaContent";
168     
169     /**
170      * A quirk flag indicating the incorrect parsing of newlines in the content of a 'textarea'.
171      * <p>
172      * This quirk occurs with:
173      * <ul>
174      * <li>Internet Explorer 6 (Windows)</li>
175      * </ul>
176      *
177      * This a more specific version of <code>QUIRK_TEXTAREA_CONTENT</code>. Now that it has been
178      * discovered that Opera has similar issues, <code>QUIRK_TEXTAREA_CONTENT</code> should be used
179      * instead.
180      */

181     public static final String JavaDoc QUIRK_IE_TEXTAREA_NEWLINE_OBLITERATION = "quirkIETextareaNewlineObliteration";
182     
183     /**
184      * A quirk flag describing the curious repaint behavior found in Internet
185      * Explorer 6, where repaints may be excessively delayed.
186      * This quirky behavior is most visible when the DOM hierarchy is large and
187      * complex.
188      * The unlikely workaround for this quirky behavior is to "tickle" (adjust
189      * and then reset) the CSS width of an element, which will force an
190      * immediate repaint.
191      * <p>
192      * This quirk occurs with:
193      * <ul>
194      * <li>Internet Explorer 6 (Windows)</li>
195      * </ul>
196      */

197     public static final String JavaDoc QUIRK_IE_REPAINT = "quirkIERepaint";
198     
199     /**
200      * A quirk flag indicating incorrect calculation of 100% table widths when within a vertically scrolling
201      * region.
202      * <p>
203      * This quirk occurs with:
204      * <ul>
205      * <li>Internet Explorer 6 (Windows)</li>
206      * </ul>
207      */

208     public static final String JavaDoc QUIRK_IE_TABLE_PERCENT_WIDTH_SCROLLBAR_ERROR = "quirkIETablePercentWidthScrollbarError";
209     
210     /**
211      * A quirk flag indicating that listbox-style select fields cannot be reliably manipulated using the client DOM API.
212      * <p>
213      * This quirk occurs with:
214      * <ul>
215      * <li>Internet Explorer 6 (Windows)</li>
216      * </ul>
217      */

218     public static final String JavaDoc QUIRK_IE_SELECT_LIST_DOM_UPDATE = "quirkIESelectListDomUpdate";
219     
220     /**
221      * A quirk flag indicating that select fields with percentage widths are not reliably rendered.
222      * <p>
223      * This quirk occurs with:
224      * <ul>
225      * <li>Internet Explorer 6 (Windows)</li>
226      * </ul>
227      */

228     public static final String JavaDoc QUIRK_IE_SELECT_PERCENT_WIDTH = "quirkIESelectPercentWidth";
229
230     // Internet Explorer-specific Proprietary Features
231
// These features are used only to compensate for IE6's lack of proper CSS support.
232

233      /**
234      * A proprietary feature flag indicating support for IE-style CSS expressions.
235      * <p>
236      * This proprietary feature is provided by:
237      * <ul>
238      * <li>Internet Explorer 6 (Windows)</li>
239      * </ul>
240      */

241     public static final String JavaDoc PROPRIETARY_IE_CSS_EXPRESSIONS_SUPPORTED = "proprietaryIECssExpressionsSupported";
242     
243     /**
244      * A proprietary feature flag indicating that PNG alpha channel support is
245      * available only by using a 'filter'.
246      * <p>
247      * This proprietary feature is provided by:
248      * <ul>
249      * <li>Internet Explorer 6 (Windows) [<em>Not neccesary with IE7 Beta 2 Refresh</em>]</li>
250      * </ul>
251      */

252     public static final String JavaDoc PROPRIETARY_IE_PNG_ALPHA_FILTER_REQUIRED = "proprietaryIEPngAlphaFilterRequired";
253     
254     /**
255      * A proprietary feature flag indicating that CSS opacity support is
256      * available only by using a 'filter'.
257      * <p>
258      * This proprietary feature is provided by:
259      * <ul>
260      * <li>Internet Explorer 6 (Windows)</li>
261      * </ul>
262      */

263     public static final String JavaDoc PROPRIETARY_IE_OPACITY_FILTER_REQUIRED = "proprietaryIEOpacityFilterRequired";
264     
265     /**
266      * A proprietary feature flag indicating that 'mouseenter' and
267      * 'mouseleave' events are supported.
268      * <p>
269      * This proprietary feature is provided by:
270      * <ul>
271      * <li>Internet Explorer 6 (Windows)</li>
272      * </ul>
273      */

274     public static final String JavaDoc PROPRIETARY_EVENT_MOUSE_ENTER_LEAVE_SUPPORTED = "proprietaryEventMouseEnterLeaveSupported";
275     
276     /**
277      * An unsupported feature flag indicating that CSS opacity effects are
278      * not supported.
279      * <p>
280      * This issue occurs with:
281      * <ul>
282      * <li>Opera</li>
283      * </ul>
284      */

285     public static final String JavaDoc NOT_SUPPORTED_CSS_OPACITY = "notSupportedCssOpacity";
286     
287     /**
288      * An unsupported feature flag indicating that manipulating CSS stylesheets is not
289      * supported by the browser (using add/insert rule).
290      * <p>
291      * This issue occurs with:
292      * <ul>
293      * <li>Safari (verified)</li>
294      * <li>KHTML (assumed)</li>
295      * </ul>
296      */

297     public static final String JavaDoc NOT_SUPPORTED_CSS_MANIPULATION = "notSupportedCssManipulation";
298     
299     // General Browser Properties
300

301     /**
302      * Width of the screen in pixels (integer).
303      */

304     public static final String JavaDoc SCREEN_WIDTH = "screenWidth";
305
306     /**
307      * Height of the screen in pixels (integer).
308      */

309     public static final String JavaDoc SCREEN_HEIGHT = "screenHeight";
310
311     /**
312      * Color depth of the screen in bits (integer).
313      */

314     public static final String JavaDoc SCREEN_COLOR_DEPTH = "screenColorDepth";
315     
316     /**
317      * Flag indicating that the browser is a derivative of the Mozilla
318      * 1.0-1.8+ browser platform.
319      */

320     public static final String JavaDoc BROWSER_MOZILLA = "browserMozilla";
321     
322     /**
323      * Flag indicating that the browser is a derivative of the Mozilla
324      * Firefox 1.0+ browser platform.
325      */

326     public static final String JavaDoc BROWSER_MOZILLA_FIREFOX = "browserMozillaFirefox";
327     
328     /**
329      * Flag indicating that the browser is a derivative of the Microsoft
330      * Internet Explorer browser platform.
331      */

332     public static final String JavaDoc BROWSER_INTERNET_EXPLORER = "browserInternetExplorer";
333     
334     /**
335      * Flag indicating that the browser is a derivative of the KDE Konqueror
336      * browser platform.
337      */

338     public static final String JavaDoc BROWSER_KONQUEROR = "browserKonqueror";
339     
340     /**
341      * Flag indicating that the browser is a derivative of the Apple Safari
342      * browser platform.
343      */

344     public static final String JavaDoc BROWSER_SAFARI = "browserSafari";
345     
346     /**
347      * Flag indicating that the browser is a derivative of the Opera
348      * browser platform.
349      */

350     public static final String JavaDoc BROWSER_OPERA = "browserOpera";
351     
352     /**
353      * The major version number of the browser.
354      */

355     public static final String JavaDoc BROWSER_VERSION_MAJOR = "browserVersionMajor";
356     
357     /**
358      * The minor version number of the browser.
359      */

360     public static final String JavaDoc BROWSER_VERSION_MINOR = "browserVersionMinor";
361     
362     /**
363      * The <code>Locale</code> of the client, derived from the language property.
364      */

365     public static final String JavaDoc LOCALES = "locales";
366     
367     /**
368      * The client's navigator.appName property.
369      */

370     public static final String JavaDoc NAVIGATOR_APP_NAME = "navigatorAppName";
371
372     /**
373      * The client's navigator.appVersion property.
374      */

375     public static final String JavaDoc NAVIGATOR_APP_VERSION = "navigatorAppVersion";
376
377     /**
378      * The client's navigator.appCodeName property.
379      */

380     public static final String JavaDoc NAVIGATOR_APP_CODE_NAME = "navigatorAppCodeName";
381
382     /**
383      * The client's navigator.cookieEnabled property.
384      */

385     public static final String JavaDoc NAVIGATOR_COOKIE_ENABLED = "navigatorCookieEnabled";
386
387     /**
388      * The client's navigator.javaEnabled property.
389      */

390     public static final String JavaDoc NAVIGATOR_JAVA_ENABLED = "navigatorJavaEnabled";
391
392     /**
393      * The client's navigator.language (or navigator.userLanguage) property.
394      */

395     public static final String JavaDoc NAVIGATOR_LANGUAGE = "navigatorLanguage";
396
397     /**
398      * The client's navigator.platform property.
399      */

400     public static final String JavaDoc NAVIGATOR_PLATFORM = "navigatorPlatform";
401
402     /**
403      * The client's navigator.userAgent property.
404      */

405     public static final String JavaDoc NAVIGATOR_USER_AGENT = "navigatorUserAgent";
406
407     /**
408      * The client host. Note this is the original host address used when the
409      * <code>ClientProperties</code> object was created, which is not
410      * necessarily the same as that making the current HTTP request.
411      */

412     public static final String JavaDoc REMOTE_HOST = "remoteHost";
413     
414     /**
415      * The client's time offset from UTC in minutes.
416      */

417     public static final String JavaDoc UTC_OFFSET = "utcOffset";
418     
419     private Map JavaDoc data = new HashMap JavaDoc();
420     
421     /**
422      * Creates a new <code>ClientProperties</code> object.
423      */

424     public ClientProperties() {
425         super();
426     }
427     
428     /**
429      * Returns the value of the specified property as an <code>Object</code>.
430      *
431      * @param propertyName the property name
432      * @return the property value
433      */

434     public Object JavaDoc get(String JavaDoc propertyName) {
435         return data.get(propertyName);
436     }
437     
438     /**
439      * Returns a <code>boolean</code> property.
440      * If the property is not set, <code>false</code> is returned.
441      *
442      * @param propertyName the property name
443      * @return the property value
444      */

445     public boolean getBoolean(String JavaDoc propertyName) {
446         Boolean JavaDoc value = (Boolean JavaDoc) data.get(propertyName);
447         return value == null ? false : value.booleanValue();
448     }
449     
450     /**
451      * Returns a <code>int</code> property.
452      * If the property is not set, <code>nullValue</code> is returned.
453      *
454      * @param propertyName the property name
455      * @param nullValue the returned value when the property is not set
456      * @return the property value
457      */

458     public int getInt(String JavaDoc propertyName, int nullValue) {
459         Integer JavaDoc value = (Integer JavaDoc) data.get(propertyName);
460         return value == null ? nullValue : value.intValue();
461     }
462     
463     /**
464      * Returns a <code>String</code> property.
465      * If the property is not set, <code>null</code> is returned.
466      *
467      * @param propertyName the property name
468      * @return the property value
469      */

470     public String JavaDoc getString(String JavaDoc propertyName) {
471         Object JavaDoc value = data.get(propertyName);
472         return value == null ? "" : value.toString();
473     }
474     
475     /**
476      * Returns an array of all property names which are set.
477      *
478      * @return the array
479      */

480     public String JavaDoc[] getPropertyNames() {
481         return (String JavaDoc[]) data.keySet().toArray(new String JavaDoc[data.size()]);
482     }
483     
484     /**
485      * Sets the value of the specified property.
486      *
487      * @param propertyName the property name
488      * @param propertyValue the property value
489      */

490     public void setProperty(String JavaDoc propertyName, Object JavaDoc propertyValue) {
491         data.put(propertyName, propertyValue);
492     }
493     
494     /**
495      * @see java.lang.Object#toString()
496      */

497     public String JavaDoc toString() {
498         return "ClientProperties: " + data.toString();
499     }
500 }
501
Popular Tags