com.autonomy.utilities
Class BrowserSniffer

java.lang.Object
  |
  +--com.autonomy.utilities.BrowserSniffer

public class BrowserSniffer
extends java.lang.Object

Interprets information about the internet browser received from the User-Agent request header field generated by browser requests


Field Summary
 java.lang.String m_sUserAgent
           
 
Constructor Summary
BrowserSniffer(javax.servlet.http.HttpServletRequest request)
          Constructor.
BrowserSniffer(java.lang.String sUserAgentHeader)
          Constructor.
 
Method Summary
 float getIEVersion()
          Returns the version of Internet Explorer, or -1 if the browser is not Internet Explorer.
 float getMozillaCompatibility()
          Returns the Mozilla compatibility of the browser of -1 if the request contains no information about the Mozilla compatibility of the browser.
static java.lang.String getUserAgentHeader(javax.servlet.http.HttpServletRequest request)
          Gets the user agent header from the HttpServletRequest object.
 boolean isBrowserIE()
          Returns true if the client browser for this request is Internet Explorer.
 void sniff()
          Extracts the relevant data from the User-Agent header.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_sUserAgent

public java.lang.String m_sUserAgent
Constructor Detail

BrowserSniffer

public BrowserSniffer(java.lang.String sUserAgentHeader)
Constructor.

Parameters:
sUserAgentHeader - string containing the contents of the User-Agent header field

BrowserSniffer

public BrowserSniffer(javax.servlet.http.HttpServletRequest request)
Constructor.

Parameters:
request - instance of a HttpServletRequest object from which the User-Agent header can be read.
Method Detail

getUserAgentHeader

public static java.lang.String getUserAgentHeader(javax.servlet.http.HttpServletRequest request)
Gets the user agent header from the HttpServletRequest object.

Parameters:
request - object to extract header from.

sniff

public void sniff()
           throws java.lang.Exception
Extracts the relevant data from the User-Agent header. The results of this can be obtained by calls to the getMozillaCompatibility, isBrowserIE and getIEVersion methods.

java.lang.Exception

isBrowserIE

public boolean isBrowserIE()
Returns true if the client browser for this request is Internet Explorer.


getIEVersion

public float getIEVersion()
Returns the version of Internet Explorer, or -1 if the browser is not Internet Explorer.


getMozillaCompatibility

public float getMozillaCompatibility()
Returns the Mozilla compatibility of the browser of -1 if the request contains no information about the Mozilla compatibility of the browser.