public class MatchMetrics extends Object implements Closeable
provider = new Provider(StreamFactory.create(
Shared.getLitePatternV32(), false));
Match match = provider.match(userAgent);
match.getDeviceId();
match.getMethod();
match.getDifference();
match.getSignature().getRank();
main assumes it is being run with a working directory at root of project or of this module.
| Modifier and Type | Field and Description |
|---|---|
protected String |
desktopUserAgent |
protected String |
mediaHubUserAgent |
protected String |
mobileUserAgent |
protected Provider |
provider |
| Constructor and Description |
|---|
MatchMetrics()
Initialises the device detection Provider with the included Lite data
file.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the
Dataset by releasing data
file readers and freeing the data file from locks. |
String |
getDeviceId(Match match)
Device ID is a string of four numeric components separated by hyphen.
|
int |
getDifference(Match match)
Extract the difference value from the
Match object provided. |
MatchMethods |
getMethod(Match match)
Extracts MatchMethods enumeration value from the
Match object. |
int |
getRank(Match match)
Extracts the signature rank from the
Match object provided. |
static void |
main(String[] args)
Main entry point for this example.
|
protected final Provider provider
protected final String mobileUserAgent
protected final String desktopUserAgent
protected final String mediaHubUserAgent
public MatchMetrics()
throws IOException
IOException - can be thrown if there is a problem reading from the
provided data file.public MatchMethods getMethod(Match match)
Match object.
The extracted value represents the algorithm used to perform this
detection.
Match object must be created and populated by invoking the
provider.match(userAgentString) before supplying to this
method.
match - Match object containing detection results, not null.public int getDifference(Match match)
Match object provided.
Difference represents the level of confidence the detector has in the
accuracy of the current detection. The higher the number the less
confident the detector is.
Difference value is only relevant to Nearest, Closest and Numeric methods. Exact method will always have a value of zero. Difference is irrelevant to None as the User-Agent that yielded this result is almost certainly fake.
Match object must be created and populated by invoking the
provider.match(userAgentString) before supplying to this
method.
match - Match object containing detection results, not null.public int getRank(Match match) throws IOException
Match object provided.
Signature rank indicates the relative level of popularity of the given
signature. The lower the value the more popular the requesting device is.
Popularity is determined by 51Degrees and is based on our statistics.
Match object must be created and populated by invoking the
provider.match(userAgentString) before supplying to this
method.
match - Match object containing detection results, not null.IOException - if there is a problem accessing the data file.public String getDeviceId(Match match) throws IOException
match - Match object containing detection results, not null.IOException - if there is a problem accessing the data file.public static void main(String[] args) throws IOException
Match object;
Match object is then passed to one of the relevant
methods to retrieve match metrics information, i.e.:
getDeviceId(fiftyone.mobile.detection.Match) is invoked to return an Id string.
args - command line arguments, not used.IOException - if there is a problem accessing the data file.public void close()
throws IOException
Dataset by releasing data
file readers and freeing the data file from locks. This method should
only be used when the Dataset is no longer required, i.e. when
device detection functionality is no longer required, or the data file
needs to be freed.close in interface Closeableclose in interface AutoCloseableIOException - if there is a problem accessing the data file.Copyright © 2017 51Degrees. All rights reserved.