KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > help > internal > webapp > data > RequestData


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.help.internal.webapp.data;
12
13 import javax.servlet.*;
14 import javax.servlet.http.*;
15
16 import org.eclipse.help.internal.base.*;
17
18 /**
19  * Helper class for contents.jsp initialization
20  */

21 public class RequestData {
22     public final static int MODE_WORKBENCH = BaseHelpSystem.MODE_WORKBENCH;
23     public final static int MODE_INFOCENTER = BaseHelpSystem.MODE_INFOCENTER;
24     public final static int MODE_STANDALONE = BaseHelpSystem.MODE_STANDALONE;
25
26     protected ServletContext context;
27     protected HttpServletRequest request;
28     protected HttpServletResponse response;
29     protected String JavaDoc locale;
30     protected WebappPreferences preferences;
31     protected boolean advancedUI;
32     /**
33      * Constructs the data for a request.
34      *
35      * @param context
36      * @param request
37      */

38     public RequestData(ServletContext context, HttpServletRequest request,
39             HttpServletResponse response) {
40         this.context = context;
41         this.request = request;
42         this.response = response;
43         preferences = new WebappPreferences();
44
45         locale = UrlUtil.getLocale(request, response);
46         String JavaDoc agent = request.getHeader("User-Agent"); //$NON-NLS-1$
47
advancedUI = UrlUtil.isAdvanced(agent);
48     }
49
50     /**
51      * Returns the preferences object
52      */

53     public WebappPreferences getPrefs() {
54         return preferences;
55     }
56
57     public boolean isBot() {
58         return UrlUtil.isBot(request);
59     }
60
61     public boolean isGecko() {
62         return UrlUtil.isGecko(request);
63     }
64
65     public boolean isIE() {
66         return UrlUtil.isIE(request);
67     }
68
69     public String JavaDoc getIEVersion() {
70         return UrlUtil.getIEVersion(request);
71     }
72
73     public boolean isKonqueror() {
74         return UrlUtil.isKonqueror(request);
75     }
76
77     public boolean isMozilla() {
78         return UrlUtil.isMozilla(request);
79     }
80
81     public String JavaDoc getMozillaVersion() {
82         return UrlUtil.getMozillaVersion(request);
83     }
84
85     public boolean isSafari() {
86         return UrlUtil.isSafari(request);
87     }
88
89     public String JavaDoc getSafariVersion() {
90         return UrlUtil.getSafariVersion(request);
91     }
92
93     public boolean isOpera() {
94         return UrlUtil.isOpera(request);
95     }
96
97     public String JavaDoc getLocale() {
98         return locale;
99     }
100
101     public int getMode() {
102         return BaseHelpSystem.getMode();
103     }
104     public boolean isAdvancedUI() {
105         return advancedUI;
106     }
107
108 }
109
Popular Tags