public class StronglyTypedValues extends Object implements Closeable
provider = new Provider(StreamFactory.create(
Shared.getLitePatternV32(), false));
Match match = provider.match(userAgent);
match.getValues("IsMobile").toBool();
| Modifier and Type | Field and Description |
|---|---|
protected String |
desktopUserAgent |
protected String |
mediaHubUserAgent |
protected String |
mobileUserAgent |
protected Provider |
provider |
| Constructor and Description |
|---|
StronglyTypedValues()
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. |
boolean |
isMobile(String userAgent)
Matches provided User-Agent string and returns the IsMobile property
value as boolean.
|
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 StronglyTypedValues()
throws IOException
IOException - can be thrown if there is a problem reading from the
provided data file.public boolean isMobile(String userAgent) throws IOException
Provider.match(java.lang.String).
Detection results are then stored in the Match object and can be
accessed using the Match.getValues("PropertyName") method.userAgent - HTTP User-Agent string.IOException - if there is a problem accessing the data file.public static void main(String[] args) throws IOException
isMobile(java.lang.String) method; and
isMobile method.
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.