|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfiftyone.device.example.illustration.StronglyTypedValues
public class StronglyTypedValues
Getting started example of using 51Degrees device detection. The example shows how to:
provider = new Provider(StreamFactory.create(
Shared.getLitePatternV32(), false));
Match match = provider.match(userAgent);
match.getValues("IsMobile").toBool();
| Field Summary | |
|---|---|
protected String |
desktopUserAgent
|
protected String |
mediaHubUserAgent
|
protected String |
mobileUserAgent
|
protected Provider |
provider
|
| Constructor Summary | |
|---|---|
StronglyTypedValues()
Initialises the device detection Provider with the included Lite data file. |
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final Provider provider
protected final String mobileUserAgent
protected final String desktopUserAgent
protected final String mediaHubUserAgent
| Constructor Detail |
|---|
public StronglyTypedValues()
throws IOException
IOException - can be thrown if there is a problem reading from the
provided data file.| Method Detail |
|---|
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 CloseableIOException - if there is a problem accessing the data file.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||