org.opencms.jsp.util
Class CmsJspDeviceSelector

java.lang.Object
  extended by org.opencms.jsp.util.CmsJspDeviceSelector
All Implemented Interfaces:
I_CmsJspDeviceSelector

public class CmsJspDeviceSelector
extends java.lang.Object
implements I_CmsJspDeviceSelector

This class provides the detection for different devices, so that the <cms:device type="...">-Tag can detect which device sends the HTTP request.

Since:
8.0.0

Field Summary
static java.lang.String C_CONSOLE
          Constant for console detection.
static java.lang.String C_DESKTOP
          Constant for desktop detection.
static java.lang.String C_MOBILE
          Constant for mobile detection.
static java.lang.String DEVICE_ANDROID
          A Smartphone name constant.
static java.lang.String DEVICE_ARCHOS
          Constant for other random devices and mobile browsers.
static java.lang.String DEVICE_BB
          A Smartphone name constant.
static java.lang.String DEVICE_BREW
          Constant for other random devices and mobile browsers.
static java.lang.String DEVICE_DANGER
          Constant for other random devices and mobile browsers.
static java.lang.String DEVICE_HIPTOP
          Constant for other random devices and mobile browsers.
static java.lang.String DEVICE_IEMOBILE
          A Smartphone name constant.
static java.lang.String DEVICE_IPHONE
          A Smartphone name constant.
static java.lang.String DEVICE_IPOD
          A Smartphone name constant.
static java.lang.String DEVICE_MIDP
          Constant for other random devices and mobile browsers.
static java.lang.String DEVICE_NINTENDO
          Constant for other random devices and mobile browsers.
static java.lang.String DEVICE_NINTENDO_DS
          Constant for other random devices and mobile browsers.
static java.lang.String DEVICE_PALM
          A Smartphone name constant.
static java.lang.String DEVICE_PDA
          Constant for other random devices and mobile browsers.
static java.lang.String DEVICE_PLAYSTATION
          Constant for other random devices and mobile browsers.
static java.lang.String DEVICE_S60
          A Smartphone name constant.
static java.lang.String DEVICE_S70
          A Smartphone name constant.
static java.lang.String DEVICE_S80
          A Smartphone name constant.
static java.lang.String DEVICE_S90
          A Smartphone name constant.
static java.lang.String DEVICE_SYMBIAN
          A Smartphone name constant.
static java.lang.String DEVICE_WII
          Constant for other random devices and mobile browsers.
static java.lang.String DEVICE_WIN_MOBILE
          A Smartphone name constant.
static java.lang.String DEVICE_WINDOWS
          A Smartphone name constant.
static java.lang.String DEVICE_XBOX
          Constant for other random devices and mobile browsers.
static java.lang.String ENGINE_BLAZER
          A Smartphone name constant.
static java.lang.String ENGINE_NETFRONT
          Constant for other random devices and mobile browsers.
static java.lang.String ENGINE_OPEN_WEB
          Constant for other random devices and mobile browsers.
static java.lang.String ENGINE_OPERA
          Constant for other random devices and mobile browsers.
static java.lang.String ENGINE_PIE
          A Smartphone name constant.
static java.lang.String ENGINE_UP_BROWSER
          Constant for other random devices and mobile browsers.
static java.lang.String ENGINE_WEBKIT
          A Smartphone name constant.
static java.lang.String ENGINE_XIINO
          A Smartphone name constant.
static java.lang.String LINUX
          Constant for other random devices and mobile browsers.
protected  java.lang.String m_httpAccept
          Accept HTTP request header.
protected  java.lang.String m_userAgent
          User-Agent HTTP request header.
static java.lang.String MAEMO
          Constant for other random devices and mobile browsers.
static java.lang.String MAEMO_TABLET
          Constant for other random devices and mobile browsers.
static java.lang.String MANU_ERICSSON
          Constant for other random devices and mobile browsers.
static java.lang.String MANU_SAMSUNG1
          Constant for other random devices and mobile browsers.
static java.lang.String MANU_SONY
          Constant for other random devices and mobile browsers.
static java.lang.String MANU_SONY_ERICSSON
          Constant for other random devices and mobile browsers.
static java.lang.String MINI
          Constant for other random devices and mobile browsers.
static java.lang.String MOBI
          Constant for other random devices and mobile browsers.
static java.lang.String MOBILE
          Constant for other random devices and mobile browsers.
static java.lang.String MYLO_COM2
          Constant for other random devices and mobile browsers.
static java.lang.String QT_EMBEDDED
          Constant for other random devices and mobile browsers.
static java.lang.String SVC_DOCOMO
          Constant for other random devices and mobile browsers.
static java.lang.String SVC_KDDI
          Constant for other random devices and mobile browsers.
static java.lang.String SVC_VODAFONE
          Constant for other random devices and mobile browsers.
static java.lang.String UPLINK
          Constant for other random devices and mobile browsers.
static java.lang.String VND_RIM
          A Smartphone name constant.
static java.lang.String VND_WAP
          Constant for mobile-specific content.
static java.lang.String WML
          Constant for mobile-specific content.
 
Fields inherited from interface org.opencms.jsp.util.I_CmsJspDeviceSelector
REQUEST_ATTRIBUTE_DEVICE
 
Constructor Summary
CmsJspDeviceSelector()
           
 
Method Summary
protected  boolean detectAndroid()
          Detects if the current device is an Android OS-based device.
protected  boolean detectAndroidWebKit()
          Detects if the current device is an Android OS-based device and the browser is based on WebKit.
protected  boolean detectArchos()
          Detects if the current device is an Archos media player/Internet tablet.
protected  boolean detectBlackBerry()
          Detects if the current browser is a BlackBerry of some sort.
protected  boolean detectBrewDevice()
          Detects whether the device is a Brew-powered device.
protected  boolean detectDangerHiptop()
          Detects the Danger Hiptop device.
protected  boolean detectGameConsole()
          Detects if the current device is an Internet-capable game console.
protected  boolean detectIphone()
          Detects if the current device is an iPhone.
protected  boolean detectIphoneOrIpod()
          Detects if the current device is an iPhone or iPod Touch.
protected  boolean detectIpod()
          Detects if the current device is an iPod Touch.
protected  boolean detectMaemoTablet()
          Detects if the current device is on one of the Maemo-based Nokia Internet Tablets.
protected  boolean detectMidpCapable()
          Detects if the current device supports MIDP, a mobile Java technology.
protected  boolean detectMobileLong()
          The longer and more thorough way to detect for a mobile device.
protected  boolean detectMobileQuick()
          The quick way to detect for a mobile device.
protected  boolean detectNintendo()
          Detects if the current device is a Nintendo game device.
protected  boolean detectOperaMobile()
          Detects Opera Mobile or Opera Mini.
protected  boolean detectPalmOS()
          Detects if the current browser is on a PalmOS device.
protected  boolean detectS60OssBrowser()
          Detects if the current browser is the S60 Open Source Browser.
protected  boolean detectSmartphone()
          Check to see whether the device is any device in the 'smartphone' category.
protected  boolean detectSonyMylo()
          Detects if the current browser is a Sony Mylo device.
protected  boolean detectSonyPlaystation()
          Detects if the current device is a Sony Playstation.
protected  boolean detectSymbianOS()
          Detects if the current device is any Symbian OS-based device, including older S60, Series 70, Series 80, Series 90, and UIQ, or other browsers running on these devices.
protected  boolean detectTierIphone()
          The quick way to detect for a tier of devices.
protected  boolean detectTierOtherPhones()
          The quick way to detect for a tier of devices.
protected  boolean detectTierSmartphones()
          The quick way to detect for a tier of devices.
protected  boolean detectWapWml()
          Detects whether the device supports WAP or WML.
protected  boolean detectWebkit()
          Detects if the current browser is based on WebKit.
protected  boolean detectWindowsMobile()
          Detects if the current browser is a Windows Mobile device.
protected  boolean detectXbox()
          Detects if the current device is a Microsoft Xbox.
 java.lang.String getDeviceType(javax.servlet.http.HttpServletRequest req)
          Returns the name of the device type.
 java.util.List<java.lang.String> getDeviceTypes()
          Returns an array of device types that can be detected.
 java.lang.String getHttpAccept()
          Return the lower case HTTP_ACCEPT.
 java.lang.String getUserAgent()
          Return the lower case HTTP_USER_AGENT.
 void init(java.lang.String userAgent, java.lang.String httpAccept)
          Initialize the userAgent and httpAccept variables.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

C_CONSOLE

public static final java.lang.String C_CONSOLE
Constant for console detection.

See Also:
Constant Field Values

C_DESKTOP

public static final java.lang.String C_DESKTOP
Constant for desktop detection.

See Also:
Constant Field Values

C_MOBILE

public static final java.lang.String C_MOBILE
Constant for mobile detection.

See Also:
Constant Field Values

DEVICE_ANDROID

public static final java.lang.String DEVICE_ANDROID
A Smartphone name constant.

See Also:
Constant Field Values

DEVICE_ARCHOS

public static final java.lang.String DEVICE_ARCHOS
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

DEVICE_BB

public static final java.lang.String DEVICE_BB
A Smartphone name constant.

See Also:
Constant Field Values

DEVICE_BREW

public static final java.lang.String DEVICE_BREW
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

DEVICE_DANGER

public static final java.lang.String DEVICE_DANGER
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

DEVICE_HIPTOP

public static final java.lang.String DEVICE_HIPTOP
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

DEVICE_IEMOBILE

public static final java.lang.String DEVICE_IEMOBILE
A Smartphone name constant.

See Also:
Constant Field Values

DEVICE_IPHONE

public static final java.lang.String DEVICE_IPHONE
A Smartphone name constant.

See Also:
Constant Field Values

DEVICE_IPOD

public static final java.lang.String DEVICE_IPOD
A Smartphone name constant.

See Also:
Constant Field Values

DEVICE_MIDP

public static final java.lang.String DEVICE_MIDP
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

DEVICE_NINTENDO

public static final java.lang.String DEVICE_NINTENDO
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

DEVICE_NINTENDO_DS

public static final java.lang.String DEVICE_NINTENDO_DS
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

DEVICE_PALM

public static final java.lang.String DEVICE_PALM
A Smartphone name constant.

See Also:
Constant Field Values

DEVICE_PDA

public static final java.lang.String DEVICE_PDA
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

DEVICE_PLAYSTATION

public static final java.lang.String DEVICE_PLAYSTATION
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

DEVICE_S60

public static final java.lang.String DEVICE_S60
A Smartphone name constant.

See Also:
Constant Field Values

DEVICE_S70

public static final java.lang.String DEVICE_S70
A Smartphone name constant.

See Also:
Constant Field Values

DEVICE_S80

public static final java.lang.String DEVICE_S80
A Smartphone name constant.

See Also:
Constant Field Values

DEVICE_S90

public static final java.lang.String DEVICE_S90
A Smartphone name constant.

See Also:
Constant Field Values

DEVICE_SYMBIAN

public static final java.lang.String DEVICE_SYMBIAN
A Smartphone name constant.

See Also:
Constant Field Values

DEVICE_WII

public static final java.lang.String DEVICE_WII
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

DEVICE_WIN_MOBILE

public static final java.lang.String DEVICE_WIN_MOBILE
A Smartphone name constant.

See Also:
Constant Field Values

DEVICE_WINDOWS

public static final java.lang.String DEVICE_WINDOWS
A Smartphone name constant.

See Also:
Constant Field Values

DEVICE_XBOX

public static final java.lang.String DEVICE_XBOX
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

ENGINE_BLAZER

public static final java.lang.String ENGINE_BLAZER
A Smartphone name constant.

See Also:
Constant Field Values

ENGINE_NETFRONT

public static final java.lang.String ENGINE_NETFRONT
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

ENGINE_OPEN_WEB

public static final java.lang.String ENGINE_OPEN_WEB
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

ENGINE_OPERA

public static final java.lang.String ENGINE_OPERA
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

ENGINE_PIE

public static final java.lang.String ENGINE_PIE
A Smartphone name constant.

See Also:
Constant Field Values

ENGINE_UP_BROWSER

public static final java.lang.String ENGINE_UP_BROWSER
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

ENGINE_WEBKIT

public static final java.lang.String ENGINE_WEBKIT
A Smartphone name constant.

See Also:
Constant Field Values

ENGINE_XIINO

public static final java.lang.String ENGINE_XIINO
A Smartphone name constant.

See Also:
Constant Field Values

LINUX

public static final java.lang.String LINUX
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

MAEMO

public static final java.lang.String MAEMO
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

MAEMO_TABLET

public static final java.lang.String MAEMO_TABLET
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

MANU_ERICSSON

public static final java.lang.String MANU_ERICSSON
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

MANU_SAMSUNG1

public static final java.lang.String MANU_SAMSUNG1
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

MANU_SONY

public static final java.lang.String MANU_SONY
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

MANU_SONY_ERICSSON

public static final java.lang.String MANU_SONY_ERICSSON
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

MINI

public static final java.lang.String MINI
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

MOBI

public static final java.lang.String MOBI
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

MOBILE

public static final java.lang.String MOBILE
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

MYLO_COM2

public static final java.lang.String MYLO_COM2
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

QT_EMBEDDED

public static final java.lang.String QT_EMBEDDED
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

SVC_DOCOMO

public static final java.lang.String SVC_DOCOMO
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

SVC_KDDI

public static final java.lang.String SVC_KDDI
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

SVC_VODAFONE

public static final java.lang.String SVC_VODAFONE
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

UPLINK

public static final java.lang.String UPLINK
Constant for other random devices and mobile browsers.

See Also:
Constant Field Values

VND_RIM

public static final java.lang.String VND_RIM
A Smartphone name constant.

See Also:
Constant Field Values

VND_WAP

public static final java.lang.String VND_WAP
Constant for mobile-specific content.

See Also:
Constant Field Values

WML

public static final java.lang.String WML
Constant for mobile-specific content.

See Also:
Constant Field Values

m_httpAccept

protected java.lang.String m_httpAccept
Accept HTTP request header.


m_userAgent

protected java.lang.String m_userAgent
User-Agent HTTP request header.

Constructor Detail

CmsJspDeviceSelector

public CmsJspDeviceSelector()
Method Detail

getDeviceType

public java.lang.String getDeviceType(javax.servlet.http.HttpServletRequest req)
Description copied from interface: I_CmsJspDeviceSelector
Returns the name of the device type.

This will be one option in I_CmsJspDeviceSelector.getDeviceTypes().

Specified by:
getDeviceType in interface I_CmsJspDeviceSelector
Parameters:
req - the HTTP servlet request to process
Returns:
the name of the device type
See Also:
I_CmsJspDeviceSelector.getDeviceType(javax.servlet.http.HttpServletRequest)

getDeviceTypes

public java.util.List<java.lang.String> getDeviceTypes()
Description copied from interface: I_CmsJspDeviceSelector
Returns an array of device types that can be detected.

Specified by:
getDeviceTypes in interface I_CmsJspDeviceSelector
Returns:
an array of device types that can be detected
See Also:
I_CmsJspDeviceSelector.getDeviceTypes()

getHttpAccept

public java.lang.String getHttpAccept()
Return the lower case HTTP_ACCEPT.

Returns:
the HTTP HEADER Accept information

getUserAgent

public java.lang.String getUserAgent()
Return the lower case HTTP_USER_AGENT.

Returns:
the user agent

init

public void init(java.lang.String userAgent,
                 java.lang.String httpAccept)
Initialize the userAgent and httpAccept variables.

Parameters:
userAgent - the User-Agent header
httpAccept - the Accept header

detectAndroid

protected boolean detectAndroid()
Detects if the current device is an Android OS-based device.

Returns:
true if the device is an Android, false otherwise

detectAndroidWebKit

protected boolean detectAndroidWebKit()
Detects if the current device is an Android OS-based device and the browser is based on WebKit.

Returns:
true if the device is an Android OS-based, false otherwise

detectArchos

protected boolean detectArchos()
Detects if the current device is an Archos media player/Internet tablet.

Returns:
true if the current device is an Archos media player/Internet tablet, false otherwise

detectBlackBerry

protected boolean detectBlackBerry()
Detects if the current browser is a BlackBerry of some sort.

Returns:
true if the current browser is a BlackBerry of some sort, false otherwise

detectBrewDevice

protected boolean detectBrewDevice()
Detects whether the device is a Brew-powered device.

Returns:
true if the device is a Brew-powered device, false otherwise

detectDangerHiptop

protected boolean detectDangerHiptop()
Detects the Danger Hiptop device.

Returns:
true if the device is a Danger Hiptop device, false otherwise

detectGameConsole

protected boolean detectGameConsole()
Detects if the current device is an Internet-capable game console.

Returns:
true if the device is an Internet-capable game console, false otherwise

detectIphone

protected boolean detectIphone()
Detects if the current device is an iPhone.

Returns:
true if the device is an iPhone, false otherwise

detectIphoneOrIpod

protected boolean detectIphoneOrIpod()
Detects if the current device is an iPhone or iPod Touch.

Returns:
true if the device is an iPhone or iPod Touch, false otherwise

detectIpod

protected boolean detectIpod()
Detects if the current device is an iPod Touch.

Returns:
true if the device is an iPod Touch, false otherwise

detectMaemoTablet

protected boolean detectMaemoTablet()
Detects if the current device is on one of the Maemo-based Nokia Internet Tablets.

Returns:
true if the current device is on one of the Maemo-based Nokia Internet Tablets, false otherwise

detectMidpCapable

protected boolean detectMidpCapable()
Detects if the current device supports MIDP, a mobile Java technology.

Returns:
true if the current device supports MIDP, a mobile Java technology, false otherwise

detectMobileLong

protected boolean detectMobileLong()
The longer and more thorough way to detect for a mobile device.

Will probably detect most feature phones, smartphone-class devices, Internet Tablets, Internet-enabled game consoles, etc. This ought to catch a lot of the more obscure and older devices, also -- but no promises on thoroughness!

Returns:
true if the current device is a mobile, a tablet or a gameconsole, false otherwise

detectMobileQuick

protected boolean detectMobileQuick()
The quick way to detect for a mobile device.

Will probably detect most recent/current mid-tier Feature Phones as well as smartphone-class devices.

Returns:
true if the device is mobile, false otherwise

detectNintendo

protected boolean detectNintendo()
Detects if the current device is a Nintendo game device.

Returns:
true if the device is a Nintendo game, false otherwise

detectOperaMobile

protected boolean detectOperaMobile()
Detects Opera Mobile or Opera Mini.

Returns:
true if the browser is a Opera Mobile or Opera Mini, false otherwise

detectPalmOS

protected boolean detectPalmOS()
Detects if the current browser is on a PalmOS device.

Returns:
true if the current browser is on a PalmOS device, false otherwise

detectS60OssBrowser

protected boolean detectS60OssBrowser()
Detects if the current browser is the S60 Open Source Browser.

Returns:
true if the current browser is the S60 Open Source Browser, false otherwise

detectSmartphone

protected boolean detectSmartphone()
Check to see whether the device is any device in the 'smartphone' category.

Returns:
true if the device is any device in the 'smartphone', false otherwise

detectSonyMylo

protected boolean detectSonyMylo()
Detects if the current browser is a Sony Mylo device.

Returns:
true if the current device is a Sony Mylo device, false otherwise

detectSonyPlaystation

protected boolean detectSonyPlaystation()
Detects if the current device is a Sony Playstation.

Returns:
true if the device is a Sony Playstation, false otherwise

detectSymbianOS

protected boolean detectSymbianOS()
Detects if the current device is any Symbian OS-based device, including older S60, Series 70, Series 80, Series 90, and UIQ, or other browsers running on these devices.

Returns:
true if the current device is any Symbian OS-based device, false otherwise

detectTierIphone

protected boolean detectTierIphone()
The quick way to detect for a tier of devices.

This method detects for devices which can display iPhone-optimized web content. Includes iPhone, iPod Touch, Android, etc.

Returns:
true if the current device from the iPhone tier, false otherwise

detectTierOtherPhones

protected boolean detectTierOtherPhones()
The quick way to detect for a tier of devices.

This method detects for all other types of phones, but excludes the iPhone and Smartphone Tier devices.

Returns:
true if the current device is mobile but not a iPhone and not a smartphone, false otherwise

detectTierSmartphones

protected boolean detectTierSmartphones()
The quick way to detect for a tier of devices.

This method detects for all smartphones, but excludes the iPhone Tier devices.

Returns:
true if the current device is a smartphone but not a iPhone, false otherwise

detectWapWml

protected boolean detectWapWml()
Detects whether the device supports WAP or WML.

Returns:
true if the device supports WAP or WML, false otherwise

detectWebkit

protected boolean detectWebkit()
Detects if the current browser is based on WebKit.

Returns:
true if the current browser is based on WebKit, false otherwise

detectWindowsMobile

protected boolean detectWindowsMobile()
Detects if the current browser is a Windows Mobile device.

Returns:
true if the current browser is a Windows Mobile device, flase otherwise

detectXbox

protected boolean detectXbox()
Detects if the current device is a Microsoft Xbox.

Returns:
true if the device is a Microsoft Xbox, false otherwise