|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfiftyone.device.example.illustration.GettingStarted
public class GettingStarted
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").toString();
| Field Summary | |
|---|---|
protected String |
desktopUserAgent
|
protected String |
mediaHubUserAgent
|
protected String |
mobileUserAgent
|
protected Provider |
provider
|
| Constructor Summary | |
|---|---|
GettingStarted()
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. |
String |
detect(String userAgent)
Matches provided User-Agent string and returns IsMobile property value. |
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 GettingStarted()
throws IOException
IOException - can be thrown if there is a problem reading from the
provided data file.| Method Detail |
|---|
public String detect(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
detect(java.lang.String) method; and
args - command line arguments, not used.
IOException - if there is a problem accessing the data file
that will be used for device detection.
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 | |||||||||