Author: rezan
Date: Tue Oct 21 01:53:35 2014
New Revision: 1633263
URL: http://svn.apache.org/r1633263
Log:
readme
Modified:
incubator/devicemap/trunk/devicemap/java/classifier/README
Modified: incubator/devicemap/trunk/devicemap/java/classifier/README
URL:
http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemap/java/classifier/README?rev=1633263&r1=1633262&r2=1633263&view=diff
==============================================================================
--- incubator/devicemap/trunk/devicemap/java/classifier/README (original)
+++ incubator/devicemap/trunk/devicemap/java/classifier/README Tue Oct 21
01:53:35 2014
@@ -1,36 +1,47 @@
devicemap-client
-To install the devicemap-client artifact locally, run:
+This client is used to classify browser User-Agent strings.
-mvn install
+This client requires devicemap-data. Data can be loaded via:
-The devicemap-client has a dependency on devicemap-data. Make sure that
artifact
-is available to this project.
-
-Once installed, the following Java code runs the client:
-
- //create a client object, store this somewhere permanent
- DeviceMapClient client = new DeviceMapClient();
-
- //load the device data, do this only once!!!
- client.initDeviceData(LoaderOption.JAR);
-
- //classify a User-Agent string
- String test = "Mozilla/5.0 (Linux; U; Android 2.2; en; HTC Aria A6380
Build/ERE27) AppleWebKit/540.13+ (KHTML, like Gecko) Version/3.1 Mobile
Safari/524.15.0";
- Map<String, String> m = client.classify(test);
+ * URL
+ * JAR file
+ * Filesystem
+
+
+ Code
+
+ //get client using JAR data source
+ DeviceMapClient client = DeviceMapFactory.getClient(LoaderOption.JAR);
+
+ //get client using data from a URL
+ //DeviceMapClient client = DeviceMapFactory.getClient(LoaderOption.URL,
"http://devicemap-vm.apache.org/data/latest");
+
+ //get client using data from a local filesystem
+ //DeviceMapClient client = DeviceMapFactory.getClient(LoaderOption.FOLDER,
"/some/path/devicemap/latest/devicedata");
+
+ String userAgent = "Mozilla/5.0 (Linux; U; Android 2.2; en; HTC Aria A6380
Build/ERE27) AppleWebKit/540.13+ (KHTML, like Gecko) Version/3.1 Mobile
Safari/524.15.0";
+
+ //classify the userAgent
+ Device device = client.classifyDevice(userAgent);
+
+ System.out.println("Device detected: " + device.getId());
//iterate thru the attributes
- for (String attr : m.keySet()) {
- System.out.println(attr + ": " + m.get(attr));
+ for (String attr : device.getAttributes().keySet()) {
+ System.out.println(attr + ": " + device.getAttribute(attr));
}
-The above code has the following devicemap dependencies:
+Maven:
<dependency>
<groupId>org.apache.devicemap</groupId>
<artifactId>devicemap-client</artifactId>
<version>1.1.0</version>
</dependency>
+
+devicemap-data JAR file:
+
<dependency>
<groupId>org.apache.devicemap</groupId>
<artifactId>devicemap-data</artifactId>