public final class BrowserVersion extends Object implements Serializable
You can create a different browser setup by using the BrowserVersionFactory.
final String applicationName = "APPNAME";
final String applicationVersion = "APPVERSION";
final String userAgent = "USERAGENT";
final BrowserVersion browser =
new BrowserVersion.BrowserVersionBuilder(BrowserVersion.FIREFOX)
.setApplicationName(applicationName)
.setApplicationVersion(applicationVersion)
.setUserAgent(userAgent)
.build();
But keep in mind this new one still behaves like an FF, 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[] |
ALL_SUPPORTED_BROWSERS
Array with all supported browsers.
|
static BrowserVersion |
BEST_SUPPORTED
The best supported browser version at the moment.
|
static BrowserVersion |
CHROME
Latest Chrome.
|
static BrowserVersion |
EDGE
Latest Edge.
|
static BrowserVersion |
FIREFOX
Latest Firefox.
|
static BrowserVersion |
FIREFOX_ESR
Firefox ESR.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getAcceptEncodingHeader()
Returns the value used by the browser for the
Accept_Encoding header. |
String |
getAcceptLanguageHeader()
Returns the value used by the browser for the
Accept_Language 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 "Netscape".
|
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".
|
Locale |
getBrowserLocale()
Returns the browser locale.
|
int |
getBrowserVersionNumeric() |
String |
getBuildId()
Returns the buildId.
|
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
FF, CHROME, etc. |
int |
getPixesPerChar() |
String |
getPlatform()
Returns the platform on which the application is running, for example "Win32".
|
String |
getProductSub()
Returns the productSub.
|
String |
getScriptAcceptHeader()
Returns the value used by the browser for the
Accept header
if requesting a script. |
String |
getSecClientHintUserAgentHeader()
Returns the value used by the browser for the
sec-ch-ua header. |
String |
getSecClientHintUserAgentPlatformHeader()
Returns the value used by the browser for the
sec-ch-ua-platform header. |
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 |
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 |
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 |
isFirefoxESR()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
boolean |
isOnLine()
Returns
true if the browser is currently online. |
boolean |
isSameBrowser(BrowserVersion other) |
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
public static final BrowserVersion FIREFOX_ESR
public static final BrowserVersion CHROME
public static final BrowserVersion EDGE
public static final BrowserVersion[] ALL_SUPPORTED_BROWSERS
public static final BrowserVersion BEST_SUPPORTED
public boolean isSameBrowser(BrowserVersion other)
other - the BrowserVersion to compare withpublic static BrowserVersion getDefault()
BEST_SUPPORTED.public static void setDefault(BrowserVersion newBrowserVersion)
newBrowserVersion - the new default browser versionpublic 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 isEdge()
true if this BrowserVersion instance represents some
version of Microsoft Edge.public boolean isFirefox()
true if this BrowserVersion instance represents some
version of Firefox.public boolean isFirefoxESR()
public String getNickname()
FF, CHROME, etc.public int getBrowserVersionNumeric()
public String getApplicationCodeName()
public String getApplicationMinorVersion()
public String getApplicationName()
public String getApplicationVersion()
public String getVendor()
public Locale getBrowserLocale()
public String getBrowserLanguage()
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()
public TimeZone getSystemTimezone()
TimeZone.
Default value is America/New_York if not explicitly configured.TimeZonepublic String getUserAgent()
public String getAcceptEncodingHeader()
Accept_Encoding header.public String getAcceptLanguageHeader()
Accept_Language 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 String getSecClientHintUserAgentHeader()
sec-ch-ua header.public String getSecClientHintUserAgentPlatformHeader()
sec-ch-ua-platform header.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()
fontSizeCopyright © 2002–2025 Gargoyle Software Inc.. All rights reserved.