public final class BrowserVersion extends Object implements Serializable
You can create a different browser setup by using the BrowserVersionFactory.
String applicationName = "APPNAME"; String applicationVersion = "APPVERSION"; String userAgent = "USERAGENT"; int browserVersionNumeric = NUMERIC; BrowserVersion browser = new BrowserVersion.BrowserVersionFactory(FF52) .setApplicationName(applicationName) .setApplicationVersion(applicationVersion) .setUserAgent(userAgent) .build();
But keep in mind this now one still behaves like a FF52, only the stuff reported to the outside is changed. This is more or less the same you can do with real browsers installing plugins like UserAgentSwitcher.
Modifier and Type | Class and Description |
---|---|
static class |
BrowserVersion.BrowserVersionBuilder
Because BrowserVersion is immutable we need a builder
for this complex object setup.
|
Modifier and Type | Field and Description |
---|---|
static BrowserVersion |
BEST_SUPPORTED
The best supported browser version at the moment.
|
static BrowserVersion |
CHROME
Latest Chrome.
|
static BrowserVersion |
FIREFOX_52
Deprecated.
as of version 2.36.0
|
static BrowserVersion |
FIREFOX_60
Firefox 60 ESR.
|
static BrowserVersion |
INTERNET_EXPLORER
Internet Explorer 11.
|
Modifier and Type | Method and Description |
---|---|
String |
getAcceptEncodingHeader()
Returns the value used by the browser for the
Accept_Encoding header. |
String |
getApplicationCodeName()
Returns the application code name, for example "Mozilla".
|
String |
getApplicationMinorVersion()
Returns the application minor version, for example "0".
|
String |
getApplicationName()
Returns the application name, for example "Microsoft Internet Explorer".
|
String |
getApplicationVersion()
Returns the application version, for example "4.0 (compatible; MSIE 6.0b; Windows 98)".
|
String |
getBrowserLanguage()
Returns the browser application language, for example "en-us".
|
int |
getBrowserVersionNumeric() |
String |
getBuildId()
Returns the buildId.
|
String |
getCpuClass()
Returns the type of CPU in the machine, for example "x86".
|
String |
getCssAcceptHeader()
Returns the value used by the browser for the
Accept header
if requesting a CSS declaration. |
static BrowserVersion |
getDefault()
Returns the default browser version that is used whenever a specific version isn't specified.
|
int |
getFontHeight(String fontSize)
Returns the corresponding height of the specified
fontSize |
String[] |
getHeaderNamesOrdered()
Gets the headers names, so they are sent in the given order (if included in the request).
|
String |
getHtmlAcceptHeader()
Returns the value used by the browser for the
Accept header if requesting a page. |
String |
getImgAcceptHeader()
Returns the value used by the browser for the
Accept header
if requesting an image. |
String |
getNickname()
Returns the short name of the browser like
FF3 , IE , etc. |
int |
getPixesPerChar() |
String |
getPlatform()
Returns the platform on which the application is running, for example "Win32".
|
Set<PluginConfiguration> |
getPlugins()
Returns the available plugins.
|
String |
getProductSub()
Returns the productSub.
|
String |
getScriptAcceptHeader()
Returns the value used by the browser for the
Accept header
if requesting a script. |
String |
getSystemLanguage()
Returns the system language, for example "en-us".
|
TimeZone |
getSystemTimezone()
Returns the system
TimeZone . |
String |
getUploadMimeType(File file)
Determines the content type for the given file.
|
String |
getUserAgent()
Returns the user agent string, for example "Mozilla/4.0 (compatible; MSIE 6.0b; Windows 98)".
|
String |
getUserLanguage()
Returns the user language, for example "en-us".
|
String |
getVendor() |
String |
getXmlHttpRequestAcceptHeader()
Returns the value used by the browser for the
Accept header
if performing an XMLHttpRequest. |
boolean |
hasFeature(BrowserVersionFeatures property)
Indicates if this instance has the given feature.
|
boolean |
isChrome()
Returns
true if this BrowserVersion instance represents some
version of Google Chrome. |
boolean |
isFirefox()
Returns
true if this BrowserVersion instance represents some
version of Firefox. |
boolean |
isFirefox52()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
boolean |
isIE()
Returns
true if this BrowserVersion instance represents some
version of Internet Explorer. |
boolean |
isOnLine()
Returns
true if the browser is currently online. |
void |
registerUploadMimeType(String fileExtension,
String mimeType)
Registers a new mime type for the provided file extension.
|
static void |
setDefault(BrowserVersion newBrowserVersion)
Sets the default browser version that is used whenever a specific version isn't specified.
|
String |
toString() |
public static final BrowserVersion FIREFOX_60
@Deprecated public static final BrowserVersion FIREFOX_52
public static final BrowserVersion INTERNET_EXPLORER
public static final BrowserVersion CHROME
public static final BrowserVersion BEST_SUPPORTED
public static BrowserVersion getDefault()
BEST_SUPPORTED
.public static void setDefault(BrowserVersion newBrowserVersion)
newBrowserVersion
- the new default browser versionpublic boolean isIE()
true
if this BrowserVersion instance represents some
version of Internet Explorer.public boolean isChrome()
true
if this BrowserVersion instance represents some
version of Google Chrome. Note that Google Chrome does not return 'Chrome'
in the application name, we have to look in the nickname.public boolean isFirefox()
true
if this BrowserVersion instance represents some
version of Firefox.public boolean isFirefox52()
public String getNickname()
FF3
, IE
, etc.public int getBrowserVersionNumeric()
public String getApplicationCodeName()
public String getApplicationMinorVersion()
public String getApplicationName()
public String getApplicationVersion()
public String getVendor()
public String getBrowserLanguage()
LANGUAGE_ENGLISH_US
if not explicitly configured.public String getCpuClass()
CPU_CLASS_X86
if not explicitly configured.public boolean isOnLine()
true
if the browser is currently online.
Default value is true
if not explicitly configured.true
if the browser is currently onlinepublic String getPlatform()
PLATFORM_WIN32
if not explicitly configured.public String getSystemLanguage()
LANGUAGE_ENGLISH_US
if not explicitly configured.public TimeZone getSystemTimezone()
TimeZone
.
Default value is America/New_York
if not explicitly configured.TimeZone
public String getUserAgent()
public String getUserLanguage()
LANGUAGE_ENGLISH_US
if not explicitly configured.public String getAcceptEncodingHeader()
Accept_Encoding
header.public String getHtmlAcceptHeader()
Accept
header if requesting a page.public String getScriptAcceptHeader()
Accept
header
if requesting a script.public String getXmlHttpRequestAcceptHeader()
Accept
header
if performing an XMLHttpRequest.public String getImgAcceptHeader()
Accept
header
if requesting an image.public String getCssAcceptHeader()
Accept
header
if requesting a CSS declaration.public Set<PluginConfiguration> getPlugins()
public boolean hasFeature(BrowserVersionFeatures property)
property
- the property namefalse
if this browser doesn't have this featurepublic String getBuildId()
public String getProductSub()
public String[] getHeaderNamesOrdered()
public void registerUploadMimeType(String fileExtension, String mimeType)
fileExtension
- the file extension used to determine the mime typemimeType
- the mime type to be used when uploading files with this extensionpublic String getUploadMimeType(File file)
file
- the filepublic int getFontHeight(String fontSize)
fontSize
fontSize
- the font sizepublic int getPixesPerChar()
fontSize
Copyright © 2002–2019 Gargoyle Software Inc.. All rights reserved.