com.jalios.util
Class Browser

java.lang.Object
  extended by com.jalios.util.Browser
All Implemented Interfaces:
Serializable

public class Browser
extends Object
implements Serializable

Analyse the user agent of a http request to determine full information about the client's browser. Can be slow, store in session attribute! Browser Detection: http://www.apptools.com/phptools/browser/source.php Robot detection: http://sitemesh.dev.java.net/

Version:
$Revision: 30881 $
See Also:
Serialized Form

Nested Class Summary
static class Browser.OS
           
 
Field Summary
protected static org.apache.oro.text.regex.Pattern botPattern
           
static String botPatternStr
           
protected  String browserName
           
protected  String browserVersion
           
protected  boolean isAndroid
           
protected  boolean isBlackberry
           
protected  boolean isChrome
           
protected  boolean isChromeFrame
           
protected  boolean isFirefox
           
protected  boolean isIE
           
protected  boolean isIE5
           
protected  boolean isIE55
           
protected  boolean isIE6
           
protected  boolean isIE7
           
protected  boolean isIE8
           
protected  boolean isIE9
           
protected  boolean isIEMobile
           
protected  boolean isIMode
           
protected  boolean isIPad
           
protected  boolean isIPhone
           
protected  boolean isModernBrowser
           
protected  boolean isOldBrowser
           
protected  boolean isOpera
           
protected  boolean isOperaMini
           
protected  boolean isRobot
           
protected  boolean isSafari
           
protected  String platform
           
static String REVISION
           
protected  String userAgent
          All known robot user-agent headers (list can be found here).
 
Constructor Summary
Browser(javax.servlet.http.HttpServletRequest request, boolean checkRemoteHost)
           
 
Method Summary
protected  void checkDevice(javax.servlet.http.HttpServletRequest request)
           
static boolean ereg(String regexp, String str)
           
static boolean eregi(String regexp, String str)
           
 String getBrowserName()
           
 String getBrowserShortName()
           
 String getBrowserVersion()
           
 String getDeviceCPU()
           
 int getDeviceScreenDepth()
           
 int getDeviceScreenHeight()
           
 int getDeviceScreenWidth()
           
 String getPlatform()
           
 String getUserAgent()
           
static double getVersion(String browserVersion)
           
static void init(String botPatternStr)
          Initialise a Robot pattern matching a given regexp
 boolean isAndroid()
           
 boolean isChrome()
           
 boolean isChromeFrame()
           
 boolean isDeviceDescribed()
           
 boolean isFirefox()
           
 boolean isIE()
           
 boolean isIE5()
           
 boolean isIE55()
           
 boolean isIE6()
           
 boolean isIE6Only()
           
 boolean isIE7()
           
 boolean isIE8()
           
 boolean isIE9()
           
 boolean isIEMobile()
           
 boolean isIMode()
           
 boolean isIPad()
           
 boolean isIPhone()
           
 boolean isKnownBrowser()
           
 boolean isModernBrowser()
           
 boolean isOldBrowser()
           
 boolean isOpera()
           
 boolean isOperaMini()
           
 boolean isPDA()
           
 boolean isRobot()
           
 boolean isSafari()
           
 boolean isSmallDevice()
          Returns true if the user-client is hosted on a small device such as a PDA or an i-mode cell phone.
static void main(String[] args)
           
 void setBrowserName(String browserName)
           
 void setBrowserVersion(String browserVersion)
           
 void setFirefox(boolean isFirefox)
           
 void setIE5(boolean isIE5)
           
 void setIE55(boolean isIE55)
           
 void setIMode(boolean isIMode)
           
 void setModernBrowser(boolean isModernBrowser)
           
 void setOldBrowser(boolean isOldBrowser)
           
 void setPlatform(String platform)
           
 void setRobot(boolean isRobot)
           
 void setUserAgent(String userAgent)
           
static String stristr(String haystack, String needle)
          Return the substring of the given haystack starting from the first occurence of the needle
 boolean supportCSS3()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

REVISION

public static final String REVISION
See Also:
Constant Field Values

userAgent

protected String userAgent
All known robot user-agent headers (list can be found here).

NOTE: To avoid bad detection:


platform

protected String platform

browserName

protected String browserName

browserVersion

protected String browserVersion

isIE

protected boolean isIE

isIE9

protected boolean isIE9

isIE8

protected boolean isIE8

isIE7

protected boolean isIE7

isIE6

protected boolean isIE6

isIE55

protected boolean isIE55

isIE5

protected boolean isIE5

isIEMobile

protected boolean isIEMobile

isFirefox

protected boolean isFirefox

isOpera

protected boolean isOpera

isOperaMini

protected boolean isOperaMini

isSafari

protected boolean isSafari

isIPhone

protected boolean isIPhone

isIPad

protected boolean isIPad

isBlackberry

protected boolean isBlackberry

isAndroid

protected boolean isAndroid

isModernBrowser

protected boolean isModernBrowser

isOldBrowser

protected boolean isOldBrowser

isChrome

protected boolean isChrome

isChromeFrame

protected boolean isChromeFrame

isRobot

protected boolean isRobot

isIMode

protected boolean isIMode

botPattern

protected static org.apache.oro.text.regex.Pattern botPattern

botPatternStr

public static String botPatternStr
Constructor Detail

Browser

public Browser(javax.servlet.http.HttpServletRequest request,
               boolean checkRemoteHost)
Method Detail

init

public static void init(String botPatternStr)
Initialise a Robot pattern matching a given regexp


checkDevice

protected void checkDevice(javax.servlet.http.HttpServletRequest request)

getDeviceCPU

public String getDeviceCPU()
Returns:
the device CPU
Since:
jcms-5.5.0

getDeviceScreenWidth

public int getDeviceScreenWidth()
Returns:
the device screen width
Since:
jcms-5.5.0

getDeviceScreenHeight

public int getDeviceScreenHeight()
Returns:
the device screen height
Since:
jcms-5.5.0

getDeviceScreenDepth

public int getDeviceScreenDepth()
Returns:
the device screen depth
Since:
jcms-5.5.0

isPDA

public boolean isPDA()
Returns:
true if the browser is hosted on a PDA
Since:
jcms-5.5.0

isSmallDevice

public boolean isSmallDevice()
Returns true if the user-client is hosted on a small device such as a PDA or an i-mode cell phone.

Returns:
true if the user-client is hosted on a small device.
Since:
jcms-5.6.0

isDeviceDescribed

public boolean isDeviceDescribed()
Returns:
true if device info are provided
Since:
jcms-5.5.0

eregi

public static boolean eregi(String regexp,
                            String str)
Parameters:
regexp - the regexp
str - the String
Returns:
true if th eregexp match
Since:
jcms-5.0.0

ereg

public static boolean ereg(String regexp,
                           String str)
Parameters:
regexp - the regexp
str - the String
Returns:
true if the regexp match with case insansitive
Since:
jcms-5.0.0

stristr

public static String stristr(String haystack,
                             String needle)
Return the substring of the given haystack starting from the first occurence of the needle

Parameters:
haystack - the String
needle - the first occurence
Returns:
the substring
Since:
jcms-5.0.0

getVersion

public static double getVersion(String browserVersion)

toString

public String toString()
Overrides:
toString in class Object

main

public static void main(String[] args)

getBrowserName

public String getBrowserName()

setBrowserName

public void setBrowserName(String browserName)

getBrowserVersion

public String getBrowserVersion()

setBrowserVersion

public void setBrowserVersion(String browserVersion)

getBrowserShortName

public String getBrowserShortName()

isFirefox

public boolean isFirefox()

setFirefox

public void setFirefox(boolean isFirefox)

isIE

public boolean isIE()

isIE5

public boolean isIE5()

setIE5

public void setIE5(boolean isIE5)

isIE55

public boolean isIE55()

setIE55

public void setIE55(boolean isIE55)

isIE6

public boolean isIE6()

isIE6Only

public boolean isIE6Only()

isIE7

public boolean isIE7()

isIE9

public boolean isIE9()

isIE8

public boolean isIE8()

isIEMobile

public boolean isIEMobile()

isChromeFrame

public boolean isChromeFrame()

isOpera

public boolean isOpera()

isOperaMini

public boolean isOperaMini()

isChrome

public boolean isChrome()

isSafari

public boolean isSafari()

isIPhone

public boolean isIPhone()

isIPad

public boolean isIPad()

isAndroid

public boolean isAndroid()

isModernBrowser

public boolean isModernBrowser()

setModernBrowser

public void setModernBrowser(boolean isModernBrowser)

isOldBrowser

public boolean isOldBrowser()

setOldBrowser

public void setOldBrowser(boolean isOldBrowser)

isKnownBrowser

public boolean isKnownBrowser()

isRobot

public boolean isRobot()

setRobot

public void setRobot(boolean isRobot)

isIMode

public boolean isIMode()
Returns:
true if this Browser is a i-mode capable browser.

setIMode

public void setIMode(boolean isIMode)

getPlatform

public String getPlatform()

setPlatform

public void setPlatform(String platform)

getUserAgent

public String getUserAgent()

setUserAgent

public void setUserAgent(String userAgent)

supportCSS3

public boolean supportCSS3()


Copyright © 2001-2010 Jalios SA. All Rights Reserved.