spring-mobile-device

org.springframework.mobile.device
Class DeviceUtils

java.lang.Object
  extended by org.springframework.mobile.device.DeviceUtils

public class DeviceUtils
extends java.lang.Object

Static helper for accessing request-scoped Device values.

Author:
Keith Donald

Field Summary
static java.lang.String CURRENT_DEVICE_ATTRIBUTE
          The name of the request attribute the current Device is indexed by.
 
Constructor Summary
DeviceUtils()
           
 
Method Summary
static Device getCurrentDevice(javax.servlet.http.HttpServletRequest request)
          Static utility method that extracts the current device from the web request.
static Device getCurrentDevice(org.springframework.web.context.request.RequestAttributes attributes)
          Static utility method that extracts the current device from the request attributes map.
static Device getRequiredCurrentDevice(javax.servlet.http.HttpServletRequest request)
          Static utility method that extracts the current device from the web request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CURRENT_DEVICE_ATTRIBUTE

public static final java.lang.String CURRENT_DEVICE_ATTRIBUTE
The name of the request attribute the current Device is indexed by. The attribute name is 'currentDevice'.

See Also:
Constant Field Values
Constructor Detail

DeviceUtils

public DeviceUtils()
Method Detail

getCurrentDevice

public static Device getCurrentDevice(javax.servlet.http.HttpServletRequest request)
Static utility method that extracts the current device from the web request. Encapsulates the ServletRequest.getAttribute(String) lookup.

Parameters:
request - the servlet request
Returns:
the current device, or null if no device has been resolved for the request

getRequiredCurrentDevice

public static Device getRequiredCurrentDevice(javax.servlet.http.HttpServletRequest request)
Static utility method that extracts the current device from the web request. Encapsulates the ServletRequest.getAttribute(String) lookup. Throws a runtime exception if the current device has not been resolved.

Parameters:
request - the servlet request
Returns:
the current device

getCurrentDevice

public static Device getCurrentDevice(org.springframework.web.context.request.RequestAttributes attributes)
Static utility method that extracts the current device from the request attributes map. Encapsulates the ServletRequest.getAttribute(String) lookup.

Parameters:
attributes - the request attributes
Returns:
the current device, or null if no device has been resolved for the request

spring-mobile-device