fiftyone.mobile.detection
Class Provider

java.lang.Object
  extended by fiftyone.mobile.detection.Provider

public class Provider
extends Object

Provider used to perform a detection based on a user agent string.


Field Summary
private  Controller controller
           
 Dataset dataSet
          The data set associated with the provider.
private  long detectionCount
           
private  SortedList<MatchMethods,Long> methodCounts
          The number of detections performed using the method.
private  Cache<String,Match.MatchState> userAgentCache
          A cache for user agents.
 
Constructor Summary
Provider()
          Builds a new provider with the embedded data set.
Provider(Dataset dataSet)
          Constructs a new provided using the data set.
Provider(Dataset dataSet, Controller controller, int cacheServiceInternal)
          Constructs a new provider with the dataset, controller and cache specified.
Provider(Dataset dataSet, int cacheServiceInterval)
          Constructs a new provided using the data set.
Provider(int cacheServiceInterval)
          Builds a new provider with the embedded data set and a cache with the service internal specified.
 
Method Summary
 Match createMatch()
          Creates a new match object to be used for matching.
 long getDetectionCount()
          The total number of detections performed by the data set.
private static String getDeviceUserAgent(Map<String,String> headers)
          Used to check other header fields in case a device user agent is being used and returns the devices useragent string.
private static byte[] getEmbeddedByteArray()
          Reads the embedded data into a byte array to be used as a byte buffer in the factory.
 Match match(Map<String,String> headers)
          For a given collection of HTTP headers returns a match containing information about the capabilities of the device and it's components.
 Match match(Map<String,String> headers, Match match)
          For a given collection of HTTP headers returns a match containing information about the capabilities of the device and it's components.
 Match match(String targetUserAgent)
          For a given user agent returns a match containing information about the capabilities of the device and it's components.
 Match match(String targetUserAgent, Match match)
          For a given user agent returns a match containing information about the capabilities of the device and it's components.
private  Match matchNoCache(String targetUserAgent, Match match)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

userAgentCache

private Cache<String,Match.MatchState> userAgentCache
A cache for user agents.


detectionCount

private long detectionCount

methodCounts

private final SortedList<MatchMethods,Long> methodCounts
The number of detections performed using the method.


dataSet

public final Dataset dataSet
The data set associated with the provider.


controller

private Controller controller
Constructor Detail

Provider

public Provider()
         throws IOException
Builds a new provider with the embedded data set.

Throws:
IOException

Provider

public Provider(int cacheServiceInterval)
         throws IOException
Builds a new provider with the embedded data set and a cache with the service internal specified.

Parameters:
cacheServiceInterval - cache service internal in seconds.
Throws:
IOException

Provider

public Provider(Dataset dataSet)
Constructs a new provided using the data set.

Parameters:
dataSet - Data set to use for device detection

Provider

public Provider(Dataset dataSet,
                int cacheServiceInterval)
Constructs a new provided using the data set.

Parameters:
cacheServiceInterval - cache service internal in seconds.
dataSet - Data set to use for device detection

Provider

Provider(Dataset dataSet,
         Controller controller,
         int cacheServiceInternal)
Constructs a new provider with the dataset, controller and cache specified.

Parameters:
dataSet -
controller -
cacheServiceInternal -
Method Detail

getDetectionCount

public long getDetectionCount()
The total number of detections performed by the data set.


getEmbeddedByteArray

private static byte[] getEmbeddedByteArray()
                                    throws IOException
Reads the embedded data into a byte array to be used as a byte buffer in the factory.

Returns:
Throws:
IOException

createMatch

public Match createMatch()
Creates a new match object to be used for matching.

Returns:
a match object ready to be used with the Match methods
Throws:
Exception

match

public Match match(Map<String,String> headers)
            throws IOException
For a given collection of HTTP headers returns a match containing information about the capabilities of the device and it's components.

Parameters:
headers - List of HTTP headers to use for the detection
Returns:
a match for the target headers provided
Throws:
IOException

match

public Match match(Map<String,String> headers,
                   Match match)
            throws IOException
For a given collection of HTTP headers returns a match containing information about the capabilities of the device and it's components.

Parameters:
headers - List of HTTP headers to use for the detection
match - object created to store the results of the match
Returns:
a match for the target headers provided
Throws:
IOException

match

public Match match(String targetUserAgent)
            throws IOException
For a given user agent returns a match containing information about the capabilities of the device and it's components.

Parameters:
targetUserAgent -
Returns:
a match result for the target user agent
Throws:
IOException

match

public Match match(String targetUserAgent,
                   Match match)
            throws IOException
For a given user agent returns a match containing information about the capabilities of the device and it's components.

Parameters:
targetUserAgent - The user agent string to use as the target
match - A match object created by a previous match, or via the CreateMatch method.
Returns:
Throws:
IOException
Exception

matchNoCache

private Match matchNoCache(String targetUserAgent,
                           Match match)
                    throws IOException
Throws:
IOException

getDeviceUserAgent

private static String getDeviceUserAgent(Map<String,String> headers)
Used to check other header fields in case a device user agent is being used and returns the devices useragent string.

Parameters:
headers - Collection of Http headers associated with the request.
Returns:
the useragent string of the device.