com.vaadin.server
Class WebBrowser

java.lang.Object
  extended by com.vaadin.server.WebBrowser
All Implemented Interfaces:
java.io.Serializable

public class WebBrowser
extends java.lang.Object
implements java.io.Serializable

Class that provides information about the web browser the user is using. Provides information such as browser name and version, screen resolution and IP address.

Author:
Vaadin Ltd.
See Also:
Serialized Form

Constructor Summary
WebBrowser()
           
 
Method Summary
 java.lang.String getAddress()
          Gets the IP-address of the web browser.
 java.lang.String getBrowserApplication()
          Get the browser user-agent string.
 int getBrowserMajorVersion()
          Gets the major version of the browser the user is using.
 int getBrowserMinorVersion()
          Gets the minor version of the browser the user is using.
 java.util.Date getCurrentDate()
          Returns the current date and time of the browser.
 int getDSTSavings()
          Gets the difference in minutes between the browser's GMT TimeZone and DST.
 java.util.Locale getLocale()
          Get the default locate of the browser.
 java.lang.Integer getRawTimezoneOffset()
          Returns the browser-reported TimeZone offset in milliseconds from GMT ignoring possible daylight saving adjustments that may be in effect in the browser.
 int getScreenHeight()
          Gets the height of the screen in pixels.
 int getScreenWidth()
          Gets the width of the screen in pixels.
 java.lang.Integer getTimezoneOffset()
          Returns the browser-reported TimeZone offset in milliseconds from GMT.
 boolean isChrome()
          Tests whether the user is using Chrome.
 boolean isChromeFrame()
          Tests whether the user is using Chrome Frame.
 boolean isChromeFrameCapable()
          Tests whether the user's browser is Chrome Frame capable.
 boolean isDSTInEffect()
          Determines whether daylight savings time (DST) is currently in effect in the region of the browser or not.
 boolean isFirefox()
          Tests whether the user is using Firefox.
 boolean isIE()
          Tests whether the user is using Internet Explorer.
 boolean isLinux()
          Tests whether the user is using Linux.
 boolean isMacOSX()
          Tests whether the user is using Mac OS X.
 boolean isOpera()
          Tests whether the user is using Opera.
 boolean isSafari()
          Tests whether the user is using Safari.
 boolean isSecureConnection()
          Is the connection made using HTTPS?
 boolean isTooOldToFunctionProperly()
          Checks if the browser is so old that it simply won't work with a Vaadin application.
 boolean isTouchDevice()
           
 boolean isWindows()
          Tests whether the user is using Windows.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebBrowser

public WebBrowser()
Method Detail

getScreenHeight

public int getScreenHeight()
Gets the height of the screen in pixels. This is the full screen resolution and not the height available for the application.

Returns:
the height of the screen in pixels.

getScreenWidth

public int getScreenWidth()
Gets the width of the screen in pixels. This is the full screen resolution and not the width available for the application.

Returns:
the width of the screen in pixels.

getBrowserApplication

public java.lang.String getBrowserApplication()
Get the browser user-agent string.

Returns:
The raw browser userAgent string

getAddress

public java.lang.String getAddress()
Gets the IP-address of the web browser. If the application is running inside a portlet, this method will return null.

Returns:
IP-address in 1.12.123.123 -format

getLocale

public java.util.Locale getLocale()
Get the default locate of the browser.


isSecureConnection

public boolean isSecureConnection()
Is the connection made using HTTPS?


isFirefox

public boolean isFirefox()
Tests whether the user is using Firefox.

Returns:
true if the user is using Firefox, false if the user is not using Firefox or if no information on the browser is present

isIE

public boolean isIE()
Tests whether the user is using Internet Explorer.

Returns:
true if the user is using Internet Explorer, false if the user is not using Internet Explorer or if no information on the browser is present

isSafari

public boolean isSafari()
Tests whether the user is using Safari.

Returns:
true if the user is using Safari, false if the user is not using Safari or if no information on the browser is present

isOpera

public boolean isOpera()
Tests whether the user is using Opera.

Returns:
true if the user is using Opera, false if the user is not using Opera or if no information on the browser is present

isChrome

public boolean isChrome()
Tests whether the user is using Chrome.

Returns:
true if the user is using Chrome, false if the user is not using Chrome or if no information on the browser is present

isChromeFrame

public boolean isChromeFrame()
Tests whether the user is using Chrome Frame.

Returns:
true if the user is using Chrome Frame, false if the user is not using Chrome or if no information on the browser is present

isChromeFrameCapable

public boolean isChromeFrameCapable()
Tests whether the user's browser is Chrome Frame capable.

Returns:
true if the user can use Chrome Frame, false if the user can not or if no information on the browser is present

getBrowserMajorVersion

public int getBrowserMajorVersion()
Gets the major version of the browser the user is using.

Note that Internet Explorer in IE7 compatibility mode might return 8 in some cases even though it should return 7.

Returns:
The major version of the browser or -1 if not known.

getBrowserMinorVersion

public int getBrowserMinorVersion()
Gets the minor version of the browser the user is using.

Returns:
The minor version of the browser or -1 if not known.
See Also:
getBrowserMajorVersion()

isLinux

public boolean isLinux()
Tests whether the user is using Linux.

Returns:
true if the user is using Linux, false if the user is not using Linux or if no information on the browser is present

isMacOSX

public boolean isMacOSX()
Tests whether the user is using Mac OS X.

Returns:
true if the user is using Mac OS X, false if the user is not using Mac OS X or if no information on the browser is present

isWindows

public boolean isWindows()
Tests whether the user is using Windows.

Returns:
true if the user is using Windows, false if the user is not using Windows or if no information on the browser is present

getTimezoneOffset

public java.lang.Integer getTimezoneOffset()
Returns the browser-reported TimeZone offset in milliseconds from GMT. This includes possible daylight saving adjustments, to figure out which TimeZone the user actually might be in, see getRawTimezoneOffset().

Returns:
timezone offset in milliseconds, 0 if not available
See Also:
getRawTimezoneOffset()

getRawTimezoneOffset

public java.lang.Integer getRawTimezoneOffset()
Returns the browser-reported TimeZone offset in milliseconds from GMT ignoring possible daylight saving adjustments that may be in effect in the browser.

You can use this to figure out which TimeZones the user could actually be in by calling TimeZone.getAvailableIDs(int).

If getRawTimezoneOffset() and getTimezoneOffset() returns the same value, the browser is either in a zone that does not currently have daylight saving time, or in a zone that never has daylight saving time.

Returns:
timezone offset in milliseconds excluding DST, 0 if not available

getDSTSavings

public int getDSTSavings()
Gets the difference in minutes between the browser's GMT TimeZone and DST.

Returns:
the amount of minutes that the TimeZone shifts when DST is in effect

isDSTInEffect

public boolean isDSTInEffect()
Determines whether daylight savings time (DST) is currently in effect in the region of the browser or not.

Returns:
true if the browser resides at a location that currently is in DST

getCurrentDate

public java.util.Date getCurrentDate()
Returns the current date and time of the browser. This will not be entirely accurate due to varying network latencies, but should provide a close-enough value for most cases. Also note that the returned Date object uses servers default time zone, not the clients.

Returns:
the current date and time of the browser.
See Also:
isDSTInEffect(), getDSTSavings(), getTimezoneOffset()

isTouchDevice

public boolean isTouchDevice()
Returns:
true if the browser is detected to support touch events

isTooOldToFunctionProperly

public boolean isTooOldToFunctionProperly()
Checks if the browser is so old that it simply won't work with a Vaadin application. Can be used to redirect to an alternative page, show alternative content or similar. When this method returns true chances are very high that the browser won't work and it does not make sense to direct the user to the Vaadin application.

Returns:
true if the browser won't work, false if not the browser is supported or might work


Copyright © 2000-2011 Vaadin Ltd. All Rights Reserved.