com.gargoylesoftware.htmlunit
Class BrowserVersion

java.lang.Object
  extended by com.gargoylesoftware.htmlunit.BrowserVersion
All Implemented Interfaces:
Serializable

public class BrowserVersion
extends Object
implements Serializable

Objects of this class represent one specific version of a given browser. Predefined constants are provided for common browser versions. If you wish to create a BrowserVersion for a browser that doesn't have a constant defined but aren't sure what values to pass into the constructor then point your browser at http://htmlunit.sourceforge.net/cgi-bin/browserVersion and the code will be generated for you.

Version:
$Revision: 2142 $
Author:
Mike Bowler, Daniel Gredler, Marc Guillemot, Chris Erskine, Ahmed Ashour
See Also:
Serialized Form

Field Summary
static String APP_CODE_NAME
          Application code name for both Microsoft Internet Explorer and Netscape series
static String CPU_CLASS_X86
          The X86 CPU class.
static BrowserVersion FIREFOX_2
          Firefox 2
static BrowserVersion FULL_FEATURED_BROWSER
          Deprecated. please use INTERNET_EXPLORER_7_0
static String INTERNET_EXPLORER
          Application name for the Microsoft Internet Explorer series of browsers
static BrowserVersion INTERNET_EXPLORER_6_0
          Internet Explorer 6
static BrowserVersion INTERNET_EXPLORER_7_0
          Internet Explorer 7
static String LANGUAGE_ENGLISH_US
          United States English language identifier.
static BrowserVersion MOZILLA_1_0
          Deprecated. please use FIREFOX_2
static String NETSCAPE
          Application name the Netscape navigator series of browsers
static BrowserVersion NETSCAPE_4_7_9
          Deprecated. please use FIREFOX_2
static BrowserVersion NETSCAPE_6_2_3
          Deprecated. please use FIREFOX_2
static String PLATFORM_WIN32
          The WIN32 platform.
 
Constructor Summary
BrowserVersion(String applicationName, String applicationVersion, String userAgent, String javaScriptVersion, float browserVersionNumeric)
          Instantiate one.
 
Method Summary
 boolean equals(Object o)
          
 String getApplicationCodeName()
          Return the application code name, for example "Mozilla".
 String getApplicationMinorVersion()
          Return the application minor version, for example "0".
 String getApplicationName()
          Return the application name, for example "Microsoft Internet Explorer".
 String getApplicationVersion()
          Return the application version, for example "4.0 (compatible; MSIE 6.0b; Windows 98)".
 String getBrowserLanguage()
          Return the browser application language, for example "en-us".
 float getBrowserVersionNumeric()
           
 String getCpuClass()
          Return the type of CPU in the machine, for example "x86".
static BrowserVersion getDefault()
          Returns the default browser version that is used whenever a specific version isn't specified.
 String getJavaScriptVersion()
          Return the version of javascript used by the browser, for example "1.2".
 float getJavaScriptVersionNumeric()
           
 String getPlatform()
          Return the platform on which the application is running, for example "Win32".
 Set getPlugins()
          Gets the configured plugins.
 String getSystemLanguage()
          Return the system language, for example "en-us".
 String getUserAgent()
          Return the user agent string, for example "Mozilla/4.0 (compatible; MSIE 6.0b; Windows 98)".
 String getUserLanguage()
          Return the user language, for example "en-us".
 int hashCode()
          
 boolean isIE()
          Returns true if this BrowserVersion instance represents some version of Microsoft Internet Explorer.
 boolean isNetscape()
          Returns true if this BrowserVersion instance represents some version of a Netscape browser, including Mozilla and Firefox.
 boolean isOnLine()
          Return true if the browser is currently online.
 void setApplicationCodeName(String applicationCodeName)
           
 void setApplicationMinorVersion(String applicationMinorVersion)
           
 void setApplicationName(String applicationName)
           
 void setApplicationVersion(String applicationVersion)
           
 void setBrowserLanguage(String browserLanguage)
           
 void setBrowserVersion(float browserVersion)
           
 void setCpuClass(String cpuClass)
           
static void setDefault(BrowserVersion newBrowserVersion)
          Sets the default browser version that is used whenever a specific version isn't specified.
 void setJavaScriptVersion(String javaScriptVersion)
           
 void setOnLine(boolean onLine)
           
 void setPlatform(String platform)
           
 void setSystemLanguage(String systemLanguage)
           
 void setUserAgent(String userAgent)
           
 void setUserLanguage(String userLanguage)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

APP_CODE_NAME

public static final String APP_CODE_NAME
Application code name for both Microsoft Internet Explorer and Netscape series

See Also:
Constant Field Values

INTERNET_EXPLORER

public static final String INTERNET_EXPLORER
Application name for the Microsoft Internet Explorer series of browsers

See Also:
Constant Field Values

NETSCAPE

public static final String NETSCAPE
Application name the Netscape navigator series of browsers

See Also:
Constant Field Values

LANGUAGE_ENGLISH_US

public static final String LANGUAGE_ENGLISH_US
United States English language identifier.

See Also:
Constant Field Values

CPU_CLASS_X86

public static final String CPU_CLASS_X86
The X86 CPU class.

See Also:
Constant Field Values

PLATFORM_WIN32

public static final String PLATFORM_WIN32
The WIN32 platform.

See Also:
Constant Field Values

FULL_FEATURED_BROWSER

public static final BrowserVersion FULL_FEATURED_BROWSER
Deprecated. please use INTERNET_EXPLORER_7_0
A fake browser that supports all the new features. This constant is used whenever you don't care which browser is being simulated.


MOZILLA_1_0

public static final BrowserVersion MOZILLA_1_0
Deprecated. please use FIREFOX_2
Mozilla 1.0


NETSCAPE_4_7_9

public static final BrowserVersion NETSCAPE_4_7_9
Deprecated. please use FIREFOX_2
Netscape 4.79


NETSCAPE_6_2_3

public static final BrowserVersion NETSCAPE_6_2_3
Deprecated. please use FIREFOX_2
Netscape 6.2.3


FIREFOX_2

public static final BrowserVersion FIREFOX_2
Firefox 2


INTERNET_EXPLORER_6_0

public static final BrowserVersion INTERNET_EXPLORER_6_0
Internet Explorer 6


INTERNET_EXPLORER_7_0

public static final BrowserVersion INTERNET_EXPLORER_7_0
Internet Explorer 7

Constructor Detail

BrowserVersion

public BrowserVersion(String applicationName,
                      String applicationVersion,
                      String userAgent,
                      String javaScriptVersion,
                      float browserVersionNumeric)
Instantiate one.

Parameters:
applicationName - The name of the application
applicationVersion - The version string of the application
userAgent - The user agent string that will be sent to the server
javaScriptVersion - The version of JavaScript
browserVersionNumeric - The floating number version of the browser
Method Detail

getDefault

public static BrowserVersion getDefault()
Returns the default browser version that is used whenever a specific version isn't specified. Defaults to INTERNET_EXPLORER_6_0.

Returns:
The default browser version.

setDefault

public static void setDefault(BrowserVersion newBrowserVersion)
Sets the default browser version that is used whenever a specific version isn't specified.

Parameters:
newBrowserVersion - The new default browser version.

isIE

public final boolean isIE()
Returns true if this BrowserVersion instance represents some version of Microsoft Internet Explorer.

Returns:
Whether or not this version is a version of IE.

isNetscape

public final boolean isNetscape()
Returns true if this BrowserVersion instance represents some version of a Netscape browser, including Mozilla and Firefox.

Returns:
Whether or not this version is a version of a Netscape browser.

getApplicationCodeName

public String getApplicationCodeName()
Return the application code name, for example "Mozilla". Default value is APP_CODE_NAME if not explicitly configured.

Returns:
The application code name.
See Also:
MSDN documentation

getApplicationMinorVersion

public String getApplicationMinorVersion()
Return the application minor version, for example "0". Default value is "0" if not explicitly configured.

Returns:
The application minor version.
See Also:
MSDN documentation

getApplicationName

public String getApplicationName()
Return the application name, for example "Microsoft Internet Explorer".

Returns:
The application name.
See Also:
MSDN documentation

getApplicationVersion

public String getApplicationVersion()
Return the application version, for example "4.0 (compatible; MSIE 6.0b; Windows 98)".

Returns:
The application version.
See Also:
MSDN documentation

getBrowserLanguage

public String getBrowserLanguage()
Return the browser application language, for example "en-us". Default value is LANGUAGE_ENGLISH_US if not explicitly configured.

Returns:
The browser application language.
See Also:
MSDN documentation

getCpuClass

public String getCpuClass()
Return the type of CPU in the machine, for example "x86". Default value is CPU_CLASS_X86 if not explicitly configured.

Returns:
The type of CPU in the machine.
See Also:
MSDN documentation

isOnLine

public boolean isOnLine()
Return true if the browser is currently online. Default value is true if not explicitly configured.

Returns:
true if the browser is currently online.
See Also:
MSDN documentation

getPlatform

public String getPlatform()
Return the platform on which the application is running, for example "Win32". Default value is PLATFORM_WIN32 if not explicitly configured.

Returns:
the platform on which the application is running.
See Also:
MSDN documentation

getSystemLanguage

public String getSystemLanguage()
Return the system language, for example "en-us". Default value is LANGUAGE_ENGLISH_US if not explicitly configured.

Returns:
The system language.
See Also:
MSDN documentation

getUserAgent

public String getUserAgent()
Return the user agent string, for example "Mozilla/4.0 (compatible; MSIE 6.0b; Windows 98)".

Returns:
The user agent string.

getUserLanguage

public String getUserLanguage()
Return the user language, for example "en-us". Default value is LANGUAGE_ENGLISH_US if not explicitly configured.

Returns:
The user language.
See Also:
MSDN documentation

getJavaScriptVersion

public String getJavaScriptVersion()
Return the version of javascript used by the browser, for example "1.2".

Returns:
the version of javascript used by the browser.

setApplicationCodeName

public void setApplicationCodeName(String applicationCodeName)
Parameters:
applicationCodeName - The applicationCodeName to set.

setApplicationMinorVersion

public void setApplicationMinorVersion(String applicationMinorVersion)
Parameters:
applicationMinorVersion - The applicationMinorVersion to set.

setApplicationName

public void setApplicationName(String applicationName)
Parameters:
applicationName - The applicationName to set.

setApplicationVersion

public void setApplicationVersion(String applicationVersion)
Parameters:
applicationVersion - The applicationVersion to set.

setBrowserLanguage

public void setBrowserLanguage(String browserLanguage)
Parameters:
browserLanguage - The browserLanguage to set.

setCpuClass

public void setCpuClass(String cpuClass)
Parameters:
cpuClass - The cpuClass to set.

setJavaScriptVersion

public void setJavaScriptVersion(String javaScriptVersion)
Parameters:
javaScriptVersion - The javaScriptVersion to set.

setOnLine

public void setOnLine(boolean onLine)
Parameters:
onLine - The onLine to set.

setPlatform

public void setPlatform(String platform)
Parameters:
platform - The platform to set.

setSystemLanguage

public void setSystemLanguage(String systemLanguage)
Parameters:
systemLanguage - The systemLanguage to set.

setUserAgent

public void setUserAgent(String userAgent)
Parameters:
userAgent - The userAgent to set.

setUserLanguage

public void setUserLanguage(String userLanguage)
Parameters:
userLanguage - The userLanguage to set.

setBrowserVersion

public void setBrowserVersion(float browserVersion)
Parameters:
browserVersion - The browserVersion to set.

getBrowserVersionNumeric

public float getBrowserVersionNumeric()
Returns:
Returns the browserVersionNumeric.

getJavaScriptVersionNumeric

public float getJavaScriptVersionNumeric()
Returns:
Returns the javaScriptVersionNumeric.

equals

public boolean equals(Object o)

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object

getPlugins

public Set getPlugins()
Gets the configured plugins. This makes only sense for Firefox as only this browser makes this kind of information available through javascript

Returns:
the available plugins


Copyright © 2002-2010 Gargoyle Software Inc.. All Rights Reserved.