Skip to main content
summaryrefslogtreecommitdiffstats
blob: 27e04fe07eac478fb1269848b8f38e41dfe70a28 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*******************************************************************************
 * Copyright (c) 2000, 2007 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.help.internal.webapp.data;

import javax.servlet.*;
import javax.servlet.http.*;

import org.eclipse.help.internal.base.*;

/**
 * Helper class for contents.jsp initialization
 */
public class RequestData {
	public final static int MODE_WORKBENCH = BaseHelpSystem.MODE_WORKBENCH;
	public final static int MODE_INFOCENTER = BaseHelpSystem.MODE_INFOCENTER;
	public final static int MODE_STANDALONE = BaseHelpSystem.MODE_STANDALONE;

	protected ServletContext context;
	protected HttpServletRequest request;
	protected HttpServletResponse response;
	protected String locale;
	protected WebappPreferences preferences;
	protected boolean advancedUI;
	/**
	 * Constructs the data for a request.
	 * 
	 * @param context
	 * @param request
	 */
	public RequestData(ServletContext context, HttpServletRequest request,
			HttpServletResponse response) {
		this.context = context;
		this.request = request;
		this.response = response;
		preferences = new WebappPreferences();

		locale = UrlUtil.getLocale(request, response);
		String agent = request.getHeader("User-Agent"); //$NON-NLS-1$
		advancedUI = UrlUtil.isAdvanced(agent);
	}

	/**
	 * Returns the preferences object
	 */
	public WebappPreferences getPrefs() {
		return preferences;
	}

	public boolean isBot() {
		return UrlUtil.isBot(request);
	}

	public boolean isGecko() {
		return UrlUtil.isGecko(request);
	}

	public boolean isIE() {
		return UrlUtil.isIE(request);
	}

	public String getIEVersion() {
		return UrlUtil.getIEVersion(request);
	}

	public boolean isKonqueror() {
		return UrlUtil.isKonqueror(request);
	}

	public boolean isMozilla() {
		return UrlUtil.isMozilla(request);
	}

	public String getMozillaVersion() {
		return UrlUtil.getMozillaVersion(request);
	}

	public boolean isSafari() {
		return UrlUtil.isSafari(request);
	}

	public String getSafariVersion() {
		return UrlUtil.getSafariVersion(request);
	}

	public boolean isOpera() {
		return UrlUtil.isOpera(request);
	}

	public String getLocale() {
		return locale;
	}

	public int getMode() {
		return BaseHelpSystem.getMode();
	}
	public boolean isAdvancedUI() {
		return advancedUI;
	}

}

Back to the top