spring-mobile-device

org.springframework.mobile.device
Class LiteDeviceResolver

java.lang.Object
  extended by org.springframework.mobile.device.LiteDeviceResolver
All Implemented Interfaces:
DeviceResolver

public class LiteDeviceResolver
extends java.lang.Object
implements DeviceResolver

A "lightweight" device resolver algorithm based on Wordpress's Mobile pack. Detects the presence of a mobile device and works for a large percentage of mobile browsers. Does not perform any device capability mapping, if you need that consider WURFL. The code is based primarily on a list of approximately 90 well-known mobile browser UA string snippets, with a couple of special cases for Opera Mini, the W3C default delivery context and certain other Windows browsers. The code also looks to see if the browser advertises WAP capabilities as a hint. Tablet resolution is also performed based on known tablet browser UA strings. Android tablets are detected based on Google's recommendations.

Author:
Keith Donald, Roy Clarkson, Scott Rossillo

Constructor Summary
LiteDeviceResolver()
           
LiteDeviceResolver(java.util.List<java.lang.String> normalUserAgentKeywords)
           
 
Method Summary
protected  java.util.List<java.lang.String> getMobileUserAgentKeywords()
          List of user agent keywords that identify mobile devices.
protected  java.util.List<java.lang.String> getMobileUserAgentPrefixes()
          List of user agent prefixes that identify mobile devices.
protected  java.util.List<java.lang.String> getNormalUserAgentKeywords()
          List of user agent keywords that identify normal devices.
protected  java.util.List<java.lang.String> getTabletUserAgentKeywords()
          List of user agent keywords that identify tablet devices.
protected  void init()
          Initialize this device resolver implementation.
 Device resolveDevice(javax.servlet.http.HttpServletRequest request)
          Resolve the device that originated the web request.
protected  Device resolveFallback(javax.servlet.http.HttpServletRequest request)
          Fallback called if no mobile device is matched by this resolver.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LiteDeviceResolver

public LiteDeviceResolver()

LiteDeviceResolver

public LiteDeviceResolver(java.util.List<java.lang.String> normalUserAgentKeywords)
Method Detail

resolveDevice

public Device resolveDevice(javax.servlet.http.HttpServletRequest request)
Description copied from interface: DeviceResolver
Resolve the device that originated the web request.

Specified by:
resolveDevice in interface DeviceResolver

getMobileUserAgentPrefixes

protected java.util.List<java.lang.String> getMobileUserAgentPrefixes()
List of user agent prefixes that identify mobile devices. Used primarily to match by operator or handset manufacturer.


getMobileUserAgentKeywords

protected java.util.List<java.lang.String> getMobileUserAgentKeywords()
List of user agent keywords that identify mobile devices. Used primarily to match by mobile platform or operating system.


getTabletUserAgentKeywords

protected java.util.List<java.lang.String> getTabletUserAgentKeywords()
List of user agent keywords that identify tablet devices. Used primarily to match by tablet platform or operating system.


getNormalUserAgentKeywords

protected java.util.List<java.lang.String> getNormalUserAgentKeywords()
List of user agent keywords that identify normal devices. Any items in this list take precedence over the mobile and tablet user agent keywords, effectively overriding those.


init

protected void init()
Initialize this device resolver implementation. Registers the known set of device signature strings. Subclasses may override to register additional strings.


resolveFallback

protected Device resolveFallback(javax.servlet.http.HttpServletRequest request)
Fallback called if no mobile device is matched by this resolver. The default implementation of this method returns a "normal" Device that is neither mobile or a tablet. Subclasses may override to try additional mobile or tablet device matching before falling back to a "normal" device.


spring-mobile-device