org.apache.turbine.util

## Class BrowserDetector

- java.lang.Object
- - org.apache.turbine.util.BrowserDetector

-     public class BrowserDetector
      extends Object

  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.
  Version:
    $Id: BrowserDetector.java 1706239 2015-10-01 13:18:35Z tv $
  Author:
    Frank Y. Kim, Leon Atkisnon, Chris Mospaw, Benjamin Elijah Griffin

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `MACINTOSH` Running on Mac OS X
    `static String` | `MOZILLA` Mozilla, Firefox and friends
    `static String` | `MSIE` Internet Explorer
    `static String` | `OPERA` Opera
    `static String` | `UNIX` Running on Unix
    `static String` | `WINDOWS` Running on Windows

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BrowserDetector(RunData data)` Constructor used to initialize this class.
    `BrowserDetector(String userAgentString)` Constructor used to initialize this class.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getBrowserName()` The browser name specified in the user agent string.
    `String` | `getBrowserPlatform()` The browser platform specified in the user agent string.
    `float` | `getBrowserVersion()` The browser version specified in the user agent string.
    `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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### MSIE

          public static final String MSIE

      Internet Explorer
      See Also:
        Constant Field Values

    - #### OPERA

          public static final String OPERA

      Opera
      See Also:
        Constant Field Values

    - #### MOZILLA

          public static final String MOZILLA

      Mozilla, Firefox and friends
      See Also:
        Constant Field Values

    - #### WINDOWS

          public static final String WINDOWS

      Running on Windows
      See Also:
        Constant Field Values

    - #### UNIX

          public static final String UNIX

      Running on Unix
      See Also:
        Constant Field Values

    - #### MACINTOSH

          public static final String MACINTOSH

      Running on Mac OS X
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### BrowserDetector

          public BrowserDetector(String userAgentString)

      Constructor used to initialize this class.
      Parameters:
        `userAgentString` - A String with the user agent field.

    - #### BrowserDetector

          public BrowserDetector(RunData data)

      Constructor used to initialize this class.
      Parameters:
        `data` - The Turbine RunData object.

  - ### Method Detail

    - #### isCssOK

          public boolean isCssOK()

      Whether or not CSS works in this browser.
      Returns:
        True if CSS works in this browser.

    - #### isFileUploadOK

          public boolean isFileUploadOK()

      Whether or not file upload works in this browser.
      Returns:
        True if file upload works in this browser.

    - #### isJavascriptOK

          public boolean isJavascriptOK()

      Whether or not Javascript works in this browser.
      Returns:
        True if Javascript works in this browser.

    - #### getBrowserName

          public String getBrowserName()

      The browser name specified in the user agent string.
      Returns:
        A String with the browser name.

    - #### getBrowserPlatform

          public String getBrowserPlatform()

      The browser platform specified in the user agent string.
      Returns:
        A String with the browser platform.

    - #### getBrowserVersion

          public float getBrowserVersion()

      The browser version specified in the user agent string.
      Returns:
        A String with the browser version.

    - #### getUserAgentString

          public String getUserAgentString()

      The user agent string for this class.
      Returns:
        A String with the user agent.

Copyright © 2000-2015 The Apache Software Foundation. All Rights Reserved.