KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > gargoylesoftware > htmlunit > javascript > host > Navigator


1 /*
2  * Copyright (c) 2002, 2005 Gargoyle Software Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * 1. Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright notice,
10  * this list of conditions and the following disclaimer in the documentation
11  * and/or other materials provided with the distribution.
12  * 3. The end-user documentation included with the redistribution, if any, must
13  * include the following acknowledgment:
14  *
15  * "This product includes software developed by Gargoyle Software Inc.
16  * (http://www.GargoyleSoftware.com/)."
17  *
18  * Alternately, this acknowledgment may appear in the software itself, if
19  * and wherever such third-party acknowledgments normally appear.
20  * 4. The name "Gargoyle Software" must not be used to endorse or promote
21  * products derived from this software without prior written permission.
22  * For written permission, please contact info@GargoyleSoftware.com.
23  * 5. Products derived from this software may not be called "HtmlUnit", nor may
24  * "HtmlUnit" appear in their name, without prior written permission of
25  * Gargoyle Software Inc.
26  *
27  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
28  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
29  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GARGOYLE
30  * SOFTWARE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
31  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
33  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
36  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37  */

38 package com.gargoylesoftware.htmlunit.javascript.host;
39
40 import org.mozilla.javascript.NativeArray;
41
42 import com.gargoylesoftware.htmlunit.BrowserVersion;
43 import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;
44
45 /**
46  * A javascript object for a Navigator.
47  *
48  * @version $Revision: 100 $
49  * @author <a HREF="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
50  * @author Daniel Gredler
51  * @author Chris Erskine
52  *
53  * @see <a HREF="http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_navigator.asp">
54  * MSDN documentation</a>
55  */

56 public final class Navigator extends SimpleScriptable {
57
58     private static final long serialVersionUID = 6741787912716453833L;
59
60
61     /**
62      * Create an instance. Javascript objects must have a default constructor.
63      */

64     public Navigator() {}
65
66
67     /**
68      * Return the property "appCodeName".
69      * @return the property "appCodeName".
70      */

71     public String JavaDoc jsxGet_appCodeName() {
72         return getBrowserVersion().getApplicationCodeName();
73     }
74
75
76     /**
77      * Return the property "appMinorVersion".
78      * @return the property "appMinorVersion".
79      */

80     public String JavaDoc jsxGet_appMinorVersion() {
81         return getBrowserVersion().getApplicationMinorVersion();
82     }
83
84
85     /**
86      * Return the property "appName".
87      * @return the property "appName".
88      */

89     public String JavaDoc jsxGet_appName() {
90         return getBrowserVersion().getApplicationName();
91     }
92
93
94     /**
95      * Return the property "appVersion".
96      * @return the property "appVersion".
97      */

98     public String JavaDoc jsxGet_appVersion() {
99         return getBrowserVersion().getApplicationVersion();
100     }
101
102
103     /**
104      * Return the language of the browser (for IE).
105      * @return the language.
106      */

107     public String JavaDoc jsxGet_browserLanguage() {
108         return getBrowserVersion().getBrowserLanguage();
109     }
110
111     /**
112      * Return the language of the browser (for Mozilla).
113      * @return the language.
114      */

115     public String JavaDoc jsxGet_language() {
116         return getBrowserVersion().getBrowserLanguage();
117     }
118
119     /**
120      * Return the property "cookieEnabled".
121      * @return the property "cookieEnabled".
122      */

123     public boolean jsxGet_cookieEnabled() {
124         return true;
125     }
126
127
128     /**
129      * Return the property "cpuClass".
130      * @return the property "cpuClass".
131      */

132     public String JavaDoc jsxGet_cpuClass() {
133         return getBrowserVersion().getCpuClass();
134     }
135
136     /**
137      * Return the property "onLine".
138      * @return the property "onLine".
139      */

140     public boolean jsxGet_onLine() {
141         return getBrowserVersion().isOnLine();
142     }
143
144
145     /**
146      * Return the property "platform".
147      * @return the property "platform".
148      */

149     public String JavaDoc jsxGet_platform() {
150         return getBrowserVersion().getPlatform();
151     }
152
153
154     /**
155      * Return the property "systemLanguage".
156      * @return the property "systemLanguage".
157      */

158     public String JavaDoc jsxGet_systemLanguage() {
159         return getBrowserVersion().getSystemLanguage();
160     }
161
162
163     /**
164      * Return the property "userAgent".
165      * @return The property "userAgent".
166      */

167     public String JavaDoc jsxGet_userAgent() {
168         return getBrowserVersion().getUserAgent();
169     }
170
171
172     /**
173      * Return the property "userLanguage".
174      * @return the property "userLanguage".
175      */

176     public String JavaDoc jsxGet_userLanguage() {
177         return getBrowserVersion().getUserLanguage();
178     }
179
180
181     /**
182      * Return an empty array because HtmlUnit does not support embedded objects.
183      * @return an empty array.
184      */

185     public Object JavaDoc jsxFunction_plugins() {
186         return new NativeArray(0);
187     }
188
189
190     /**
191      * Return <tt>false</tt> always as Java support is not enabled in HtmlUnit.
192      * @return false.
193      */

194     public boolean jsxFunction_javaEnabled() {
195         return false;
196     }
197
198
199     /**
200      * Return <tt>false</tt> always as data tainting support is not enabled in HtmlUnit.
201      * @return false.
202      */

203     public boolean jsxFunction_taintEnabled() {
204         return false;
205     }
206
207
208     /**
209      * Returns the default browser version.
210      * @return the default browser version.
211      */

212     private BrowserVersion getBrowserVersion() {
213         return getPageInfo().getScope().getWebWindow().getWebClient().getBrowserVersion();
214     }
215
216 }
217
Popular Tags