|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.juniverse.utils.BrowserDetector
This class is original from the Apache Turbine Project.
This class parses the user agent string and sets javasciptOK and
cssOK following the rules described below. If you want to check
for specific browsers/versions then use this class to parse the
user agent string and use the accessor methods in this class.
JavaScriptOK means that the browser understands JavaScript on the
same level the Navigator 3 does. Specifically, it can use named
images. This allows easier rollovers. If a browser doesn't do
this (Nav 2 or MSIE 3), then we just assume it can't do any
JavaScript. Referencing images by load order is too hard to
maintain.
CSSOK is kind of sketchy in that Nav 4 and MSIE work differently,
but they do seem to have most of the functionality. MSIE 4 for the
Mac has buggy CSS support, so we let it do JavaScript, but no CSS.
Ported from Leon's PHP code at
http://www.working-dogs.com/freetrade by Frank.
Field Summary | |
private java.lang.String |
browserName
The browser name specified in the user agent string. |
private java.lang.String |
browserPlatform
The browser platform specified in the user agent string. |
private float |
browserVersion
The browser version specified in the user agent string. |
private boolean |
cssOK
Whether or not CSS works in this browser. |
private boolean |
fileUploadOK
Whether or not file upload works in this browser. |
private boolean |
javascriptOK
Whether or not javascript works in this browser. |
static java.lang.String |
MACINTOSH
|
static java.lang.String |
MOZILLA
|
static java.lang.String |
MSIE
Constants used by this class. |
static java.lang.String |
OPERA
|
static java.lang.String |
UNIX
|
private java.lang.String |
userAgentString
The user agent string. |
static java.lang.String |
WINDOWS
|
Constructor Summary | |
BrowserDetector(javax.servlet.http.HttpServletRequest request)
Constructor used to initialize this class. |
|
BrowserDetector(java.lang.String userAgentString)
Constructor used to initialize this class. |
Method Summary | |
java.lang.String |
getBrowserName()
The browser name specified in the user agent string. |
java.lang.String |
getBrowserPlatform()
The browser platform specified in the user agent string. |
float |
getBrowserVersion()
The browser version specified in the user agent string. |
java.lang.String |
getUserAgentString()
The user agent string for this class. |
boolean |
isCssOK()
Whether or not CSS works in this browser. |
boolean |
isFileUploadOK()
Whether or not file upload works in this browser. |
boolean |
isJavascriptOK()
Whether or not Javascript works in this browser. |
private void |
parse()
Helper method to initialize this class. |
private float |
toFloat(java.lang.String s)
Helper method to conver String to a float. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private java.lang.String userAgentString
private java.lang.String browserName
private float browserVersion
private java.lang.String browserPlatform
private boolean javascriptOK
private boolean cssOK
private boolean fileUploadOK
public static final java.lang.String MSIE
public static final java.lang.String OPERA
public static final java.lang.String MOZILLA
public static final java.lang.String WINDOWS
public static final java.lang.String UNIX
public static final java.lang.String MACINTOSH
Constructor Detail |
public BrowserDetector(java.lang.String userAgentString)
userAgentString
- A String with the user agent field.public BrowserDetector(javax.servlet.http.HttpServletRequest request)
request
- a HttpServletRequestMethod Detail |
public boolean isCssOK()
public boolean isFileUploadOK()
public boolean isJavascriptOK()
public java.lang.String getBrowserName()
public java.lang.String getBrowserPlatform()
public float getBrowserVersion()
public java.lang.String getUserAgentString()
private void parse()
private float toFloat(java.lang.String s)
s
- A String.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |