You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devicemap.apache.org by wk...@apache.org on 2014/07/29 02:02:46 UTC

svn commit: r1614222 - /incubator/devicemap/trunk/examples/console/src/main/java/org/apache/devicemap/example/console/Example.java

Author: wkeil
Date: Tue Jul 29 00:02:45 2014
New Revision: 1614222

URL: http://svn.apache.org/r1614222
Log:
DMAP-54: Improve Console example 

Task-Url: https://issues.apache.org/jira/browse/DMAP-54

Modified:
    incubator/devicemap/trunk/examples/console/src/main/java/org/apache/devicemap/example/console/Example.java

Modified: incubator/devicemap/trunk/examples/console/src/main/java/org/apache/devicemap/example/console/Example.java
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/examples/console/src/main/java/org/apache/devicemap/example/console/Example.java?rev=1614222&r1=1614221&r2=1614222&view=diff
==============================================================================
--- incubator/devicemap/trunk/examples/console/src/main/java/org/apache/devicemap/example/console/Example.java (original)
+++ incubator/devicemap/trunk/examples/console/src/main/java/org/apache/devicemap/example/console/Example.java Tue Jul 29 00:02:45 2014
@@ -43,17 +43,30 @@ public class Example {
         if (args != null && args.length > 0) {
         	test = args[0];
         }
-        
-        final Map<String, String> m = client.classify(test);
-        
-        //iterate thru the attributes
-        if (m!=null && (m.keySet()!= null && m.keySet().size()>0)) {
-	        System.out.println("### ATTRIBUTES ###");
-	        for (String attr : m.keySet()) {
-	            System.out.println(attr + ": " + m.get(attr));
-	        }
+        if (test!= null && test.length()>0) {
+        	if ("--usage".equals(test)) {
+        		System.out.println("### USAGE ###");
+        		System.out.println("ua=\"<User Agent>\"");
+        		System.out.println("");
+        		System.out.println("If you don't pass an argument, a default user agent will be applied.");
+        	} else {
+	        	if (test.startsWith("ua=")) {
+	        		test = test.substring(3);
+	        	}
+		        final Map<String, String> m = client.classify(test);
+		        
+		        //iterate thru the attributes
+		        if (m!=null && (m.keySet()!= null && m.keySet().size()>0)) {
+			        System.out.println("### ATTRIBUTES ###");
+			        for (String attr : m.keySet()) {
+			            System.out.println(attr + ": " + m.get(attr));
+			        }
+		        } else {
+		        	System.out.println("No device or attributes found for '" + test + "'.");
+		        }
+        	}
         } else {
-        	System.out.println("No device or attributes found for '" + test + "'.");
+        	System.out.println("No device or attributes given.");
         }
     }
 }