net.sourceforge.wurfl.core.utils
Class UserAgentUtils

java.lang.Object
  extended by net.sourceforge.wurfl.core.utils.UserAgentUtils

public final class UserAgentUtils
extends Object

User-Agent helper class.

This class have several utility methods to support the user-agent matching.

Version:
$Id: UserAgentUtils.java 432 2010-05-06 12:12:53Z filippo.deluca $
Author:
Fantayeneh Asres Gizaw, Filippo De Luca

Field Summary
static Pattern nameSpacePattern
          Compiled pattern to parse UAProfile namespace
static Pattern stripQuotePattern
          Compiled pattern to strip out quotes in UAProfile
 
Method Summary
static String getUaProfile(javax.servlet.http.HttpServletRequest request)
          This method parse the HTTP request to obtain the UAProf URL.
static String getUserAgent(javax.servlet.http.HttpServletRequest request)
          This method parse the Http request to find the user-agent string.
static boolean isBot(String userAgent)
           
static org.apache.commons.collections.Predicate isContainedIn(String userAgent)
           
static boolean isDesktopBrowser(String userAgent)
           
static boolean isMobileBrowser(String userAgent)
           
static boolean isXhtmlRequester(javax.servlet.http.HttpServletRequest httpRequest)
          This method return true if HTTP request is came from a Xhtml enable device.
static Set keys(String propertyFile)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stripQuotePattern

public static final Pattern stripQuotePattern
Compiled pattern to strip out quotes in UAProfile


nameSpacePattern

public static final Pattern nameSpacePattern
Compiled pattern to parse UAProfile namespace

Method Detail

getUserAgent

public static String getUserAgent(javax.servlet.http.HttpServletRequest request)
This method parse the Http request to find the user-agent string. It search first the UA request parameter and then across x-device-user-agent and User-Agent header value.

Parameters:
request - The HttpServletRequest to parse. It must be not null value.
Returns:
The user-agent string reported by the Http request.

getUaProfile

public static String getUaProfile(javax.servlet.http.HttpServletRequest request)
This method parse the HTTP request to obtain the UAProf URL.

It search across the x-wap-profile,Profile and wap-profile to find the UAProf URL. If this headers returns a null value it try to obtain right header to read, parsing the Opt header.

Parameters:
request - The HttpServletRequest parsed to obtain UAProf, it must be not null.
Returns:
a String containing the UAProf URL.

isXhtmlRequester

public static boolean isXhtmlRequester(javax.servlet.http.HttpServletRequest httpRequest)
This method return true if HTTP request is came from a Xhtml enable device.

It parse the accept header to find some keyword, that demonstrate the device support Xhtml content.

Parameters:
httpRequest - The HttpServletRequest from target device, it must be not null.
Returns:
true, if the requester device support Xhtml content, false otherwise.

keys

public static Set keys(String propertyFile)

isMobileBrowser

public static boolean isMobileBrowser(String userAgent)

isDesktopBrowser

public static boolean isDesktopBrowser(String userAgent)

isBot

public static boolean isBot(String userAgent)

isContainedIn

public static org.apache.commons.collections.Predicate isContainedIn(String userAgent)


Copyright © 2008-2010 WURFL-Pro srl. All Rights Reserved.