public class Provider extends Object
Provider requires a Dataset object connected to one of the 51Degrees
device data files in order to perform device detection. Can be created like:
Provider p = new Provider(StreamFactory.create("path_to_file"));
Provider p = new Provider(MemoryFactory.create("path_to_file"));
Match methods return a Match object that contains detection results
for a specific User-Agent string, collection of HTTP headers of a device Id.
Use it to retrieve detection results like:
match.getValues("IsMobile");
You can access the underlying data set like:
provider.dataset.publised to retrieve various meta information like
the published date and the next update date as well as the list of various
entities like profiles and properties.
Remember to close the underlying data set when
program finishes to release resources and remove file lock.
| Modifier and Type | Field and Description |
|---|---|
Dataset |
dataSet
The data set associated with the provider.
|
| Constructor and Description |
|---|
Provider(Dataset dataSet)
Constructs a new Provider using the data set without a cache.
|
Provider(Dataset dataSet,
int cacheSize)
Constructs a new Provider using the data set, with a cache of the size
provided.
|
| Modifier and Type | Method and Description |
|---|---|
Match |
createMatch()
Creates a new match instance to be used for matching.
|
long |
getCacheMisses() |
double |
getCacheRequests() |
long |
getCacheSwitches()
Deprecated.
|
long |
getDetectionCount()
The total number of detections performed by the data set.
|
double |
getPercentageCacheMisses() |
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.
|
Match |
matchForDeviceId(ArrayList<Integer> profileIds)
Returns the result of a match based on the device Id returned from a
previous match operation.
|
Match |
matchForDeviceId(ArrayList<Integer> profileIds,
Match match)
Returns the result of a match based on the device Id returned from a
previous match operation.
|
Match |
matchForDeviceId(byte[] deviceIdArray)
Returns the result of a match based on the device Id returned from a
previous match operation.
|
Match |
matchForDeviceId(byte[] deviceIdArray,
Match match)
Returns the result of a match based on the device Id returned from a
previous match operation.
|
Match |
matchForDeviceId(String deviceId)
Returns the result of a match based on the device Id returned from a
previous match operation.
|
Match |
matchForDeviceId(String deviceId,
Match match)
Returns the result of a match based on the device Id returned from a
previous match operation.
|
public final Dataset dataSet
public Provider(Dataset dataSet)
dataSet - to use for device detectionpublic Provider(Dataset dataSet, int cacheSize)
dataSet - to use for device detectioncacheSize - to be used with the provider, 0 for no cachepublic long getDetectionCount()
public double getPercentageCacheMisses()
@Deprecated public long getCacheSwitches()
public double getCacheRequests()
public long getCacheMisses()
public Match createMatch()
public Match match(Map<String,String> headers) throws IOException
headers - List of HTTP headers to use for the detection.Match object with detection results.IOException - if there was a problem accessing data file.public Match match(Map<String,String> headers, Match match) throws IOException
headers - List of HTTP headers to use for the detection.match - A match object created by a previous match, or via the
createMatch() method, not null.Match object with detection results.IOException - if there was a problem accessing data file.public Match match(String targetUserAgent) throws IOException
targetUserAgent - User-Agent string to be identified.Match object with detection results.IOException - if there was a problem accessing data file.public Match match(String targetUserAgent, Match match) throws IOException
targetUserAgent - User-Agent string to be identified.match - A match object created by a previous match, or via the
CreateMatch method.Match object with detection results.IOException - if there was a problem accessing data file.public Match matchForDeviceId(byte[] deviceIdArray) throws IOException
deviceIdArray - Byte array representation of the device Id, not null.Match object with detection results.IOException - if there was a problem accessing data file.public Match matchForDeviceId(String deviceId) throws IOException
deviceId - String representation of the device Id, not null.Match object with detection results.IOException - if there was a problem accessing data file.public Match matchForDeviceId(ArrayList<Integer> profileIds) throws IOException
profileIds - List of profile IDs as integers, not null.Match object with detection results.IOException - if there was a problem accessing data file.public Match matchForDeviceId(byte[] deviceIdArray, Match match) throws IOException
deviceIdArray - Byte array representation of the device Id.match - A match object created by a previous match, or via the
createMatch() method, not null.Match object with detection results.IOException - if there was a problem accessing data file.public Match matchForDeviceId(String deviceId, Match match) throws IOException
deviceId - String representation of the device Id.match - A match object created by a previous match, or via the
createMatch() method, not null.Match object with detection results.IOException - if there was a problem accessing data file.public Match matchForDeviceId(ArrayList<Integer> profileIds, Match match) throws IOException
profileIds - List of profile IDs as integers.match - A match object created by a previous match, or via the
createMatch() method.Match object with detection results.IOException - if there was a problem accessing data file.Copyright © 2015 51Degrees. All rights reserved.