public class BrowserVersion extends Object implements Serializable, Cloneable
You can change the constants by something like:
String applicationName = "APPNAME"; String applicationVersion = "APPVERSION"; String userAgent = "USERAGENT"; int browserVersionNumeric = NUMERIC; BrowserVersion browser = new BrowserVersion(applicationName, applicationVersion, userAgent, browserVersionNumeric) { public boolean hasFeature(BrowserVersionFeatures property) { // change features here return BrowserVersion.BROWSER.hasFeature(property); } };However, note that the constants are not enough to fully customize the browser, you also need to look into the
BrowserVersionFeatures
and the classes inside "javascript" package.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 |
EDGE
Microsoft Edge.
|
static BrowserVersion |
FIREFOX_38
Deprecated.
as of 2.23, please use
FIREFOX_45 |
static BrowserVersion |
FIREFOX_45
Firefox 45 ESR.
|
static BrowserVersion |
INTERNET_EXPLORER
Internet Explorer 11.
|
static BrowserVersion |
INTERNET_EXPLORER_11
Deprecated.
as of 2.20, please use
INTERNET_EXPLORER instead |
Constructor and Description |
---|
BrowserVersion(String applicationName,
String applicationVersion,
String userAgent,
int browserVersionNumeric)
Instantiates one.
|
BrowserVersion(String applicationName,
String applicationVersion,
String userAgent,
int browserVersionNumeric,
BrowserVersionFeatures[] features)
Instantiates one.
|
Modifier and Type | Method and Description |
---|---|
BrowserVersion |
clone()
Creates and return a copy of this object.
|
boolean |
equals(Object o) |
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.
|
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. |
String |
getPlatform()
Returns the platform on which the application is running, for example "Win32".
|
Set<PluginConfiguration> |
getPlugins()
Returns the available plugins.
|
String |
getScriptAcceptHeader()
Returns the value used by the browser for the
Accept header
if requesting an script. |
String |
getSystemLanguage()
Returns the system language, for example "en-us".
|
String |
getUploadMimeTypeFor(String fileExtension) |
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.
|
int |
hashCode() |
boolean |
isChrome()
Returns
true if this BrowserVersion instance represents some
version of Google Chrome. |
boolean |
isEdge()
Returns
true if this BrowserVersion instance represents some
version of Microsoft Edge. |
boolean |
isFirefox()
Returns
true if this BrowserVersion instance represents some
version of Firefox. |
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.
|
void |
setApplicationCodeName(String applicationCodeName) |
void |
setApplicationMinorVersion(String applicationMinorVersion) |
void |
setApplicationName(String applicationName) |
void |
setApplicationVersion(String applicationVersion) |
void |
setBrowserLanguage(String browserLanguage) |
void |
setBrowserVersion(int browserVersion) |
void |
setCpuClass(String cpuClass) |
void |
setCssAcceptHeader(String cssAcceptHeader) |
static void |
setDefault(BrowserVersion newBrowserVersion)
Sets the default browser version that is used whenever a specific version isn't specified.
|
void |
setHeaderNamesOrdered(String[] headerNames)
Sets the headers names, so they are sent in the given order (if included in the request).
|
void |
setHtmlAcceptHeader(String htmlAcceptHeader) |
void |
setImgAcceptHeader(String imgAcceptHeader) |
void |
setOnLine(boolean onLine) |
void |
setPlatform(String platform) |
void |
setScriptAcceptHeader(String scriptAcceptHeader) |
void |
setSystemLanguage(String systemLanguage) |
void |
setUserAgent(String userAgent) |
void |
setUserLanguage(String userLanguage) |
void |
setVendor(String vendor) |
void |
setXmlHttpRequestAcceptHeader(String xmlHttpRequestAcceptHeader) |
String |
toString() |
@Deprecated public static final BrowserVersion FIREFOX_38
FIREFOX_45
public static final BrowserVersion FIREFOX_45
public static final BrowserVersion INTERNET_EXPLORER
@Deprecated public static final BrowserVersion INTERNET_EXPLORER_11
INTERNET_EXPLORER
insteadpublic static final BrowserVersion CHROME
public static final BrowserVersion EDGE
public static final BrowserVersion BEST_SUPPORTED
public BrowserVersion(String applicationName, String applicationVersion, String userAgent, int browserVersionNumeric)
applicationName
- the name of the applicationapplicationVersion
- the version string of the applicationuserAgent
- the user agent string that will be sent to the serverbrowserVersionNumeric
- the number version of the browserpublic BrowserVersion(String applicationName, String applicationVersion, String userAgent, int browserVersionNumeric, BrowserVersionFeatures[] features)
applicationName
- the name of the applicationapplicationVersion
- the version string of the applicationuserAgent
- the user agent string that will be sent to the serverbrowserVersionNumeric
- the number version of the browserfeatures
- the browser featurespublic static BrowserVersion getDefault()
BEST_SUPPORTED
.public static void setDefault(BrowserVersion newBrowserVersion)
newBrowserVersion
- the new default browser versionpublic final boolean isIE()
true
if this BrowserVersion instance represents some
version of Internet Explorer.public final 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 final boolean isEdge()
true
if this BrowserVersion instance represents some
version of Microsoft Edge.public final boolean isFirefox()
true
if this BrowserVersion instance represents some
version of Firefox.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 String getUserAgent()
public String getUserLanguage()
LANGUAGE_ENGLISH_US
if not explicitly configured.public String getHtmlAcceptHeader()
Accept
header if requesting a page.public String getScriptAcceptHeader()
Accept
header
if requesting an 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 void setApplicationCodeName(String applicationCodeName)
applicationCodeName
- the applicationCodeName to setpublic void setApplicationMinorVersion(String applicationMinorVersion)
applicationMinorVersion
- the applicationMinorVersion to setpublic void setApplicationName(String applicationName)
applicationName
- the applicationName to setpublic void setApplicationVersion(String applicationVersion)
applicationVersion
- the applicationVersion to setpublic void setVendor(String vendor)
vendor
- the vendor to setpublic void setBrowserLanguage(String browserLanguage)
browserLanguage
- the browserLanguage to setpublic void setCpuClass(String cpuClass)
cpuClass
- the cpuClass to setpublic void setOnLine(boolean onLine)
onLine
- the onLine to setpublic void setPlatform(String platform)
platform
- the platform to setpublic void setSystemLanguage(String systemLanguage)
systemLanguage
- the systemLanguage to setpublic void setUserAgent(String userAgent)
userAgent
- the userAgent to setpublic void setUserLanguage(String userLanguage)
userLanguage
- the userLanguage to setpublic void setBrowserVersion(int browserVersion)
browserVersion
- the browserVersion to setpublic void setHtmlAcceptHeader(String htmlAcceptHeader)
htmlAcceptHeader
- the Accept
header to be used when retrieving pagespublic void setImgAcceptHeader(String imgAcceptHeader)
imgAcceptHeader
- the Accept
header to be used when retrieving imagespublic void setCssAcceptHeader(String cssAcceptHeader)
cssAcceptHeader
- the Accept
header to be used when retrieving pagespublic void setScriptAcceptHeader(String scriptAcceptHeader)
scriptAcceptHeader
- the Accept
header to be used when retrieving scriptspublic void setXmlHttpRequestAcceptHeader(String xmlHttpRequestAcceptHeader)
xmlHttpRequestAcceptHeader
- the Accept
header to be used when
performing XMLHttpRequestspublic int getBrowserVersionNumeric()
public Set<PluginConfiguration> getPlugins()
public boolean hasFeature(BrowserVersionFeatures property)
property
- the property namefalse
if this browser doesn't have this featurepublic String getNickname()
FF3
, IE
, etc.public String getBuildId()
public String[] getHeaderNamesOrdered()
public void setHeaderNamesOrdered(String[] headerNames)
headerNames
- the header names in ordered mannerpublic 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 getUploadMimeTypeFor(String fileExtension)
fileExtension
- the file extension used to determine the mime typepublic BrowserVersion clone()
Copyright © 2002–2019 Gargoyle Software Inc.. All rights reserved.