devicemap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wk...@apache.org
Subject svn commit: r1648964 - /devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/
Date Fri, 02 Jan 2015 00:38:43 GMT
Author: wkeil
Date: Fri Jan  2 00:38:43 2015
New Revision: 1648964

URL: http://svn.apache.org/r1648964
Log:
DMAP-118: Replace SLF4J/JUL/System.out with Log4J 2 

Task-Url: https://issues.apache.org/jira/browse/DMAP-118
DMAP-111: Improve Web Examples 

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

Modified:
    devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/AndroidDeviceBuilder.java
    devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/BotDeviceBuilder.java
    devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/DesktopOSDeviceBuilder.java
    devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/SymbianDeviceBuilder.java
    devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/TwoStepDeviceBuilder.java
    devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/WinPhoneDeviceBuilder.java

Modified: devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/AndroidDeviceBuilder.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/AndroidDeviceBuilder.java?rev=1648964&r1=1648963&r2=1648964&view=diff
==============================================================================
--- devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/AndroidDeviceBuilder.java
(original)
+++ devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/AndroidDeviceBuilder.java
Fri Jan  2 00:38:43 2015
@@ -238,8 +238,10 @@ public class AndroidDeviceBuilder extend
     		String[] parts = pattern.split(";");
     		for (String part : parts) {
     			if (part.trim().startsWith("Android")) {
-    				String versionPart = part.trim().substring("Android".length());
-    				if (!versionPart.equals(device.get("device_os_version"))) {
+    				final String versionPart = part.trim().substring("Android".length());
+    				final String versionExisting = device.get("device_os_version");
+    				if (!versionPart.equals(versionExisting)) {
+    					logger.info("Fixing '" + versionExisting +"' to '" + versionPart + "'" );
     					device.putProperty("device_os_version", versionPart);
     				}
     			}

Modified: devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/BotDeviceBuilder.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/BotDeviceBuilder.java?rev=1648964&r1=1648963&r2=1648964&view=diff
==============================================================================
--- devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/BotDeviceBuilder.java
(original)
+++ devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/BotDeviceBuilder.java
Fri Jan  2 00:38:43 2015
@@ -18,68 +18,9 @@
  */
 package org.apache.devicemap.simpleddr.builder.device;
 
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-import org.apache.devicemap.simpleddr.model.device.Device;
-import org.apache.devicemap.simpleddr.model.BuiltObject;
-import org.apache.devicemap.simpleddr.model.UserAgent;
-
-public class BotDeviceBuilder implements DeviceBuilder {
-
-	private final Map<String, String> simpleTokenMap;
-	private Map<String, Device> devices;
+public class BotDeviceBuilder extends SimpleDeviceBuilder {
 
 	public BotDeviceBuilder() {
-		simpleTokenMap = new LinkedHashMap<String, String>();
-	}
-
-	public void putDevice(String deviceId, List<String> initProperties) {
-
-		for (String token : initProperties) {
-			simpleTokenMap.put(token, deviceId);
-		}
-	}
-
-	public void completeInit(Map<String, Device> devices) {
-		this.devices = devices;
-
-		for (String deviceID : simpleTokenMap.values()) {
-			if (!devices.containsKey(deviceID)) {
-				throw new IllegalStateException(
-						"unable to find device with id: " + deviceID
-								+ "in devices");
-			}
-		}
-	}
-
-	public boolean canBuild(UserAgent userAgent) {
-		for (String token : simpleTokenMap.keySet()) {
-			if (userAgent.getCompleteUserAgent().matches(
-					"(?i).*" + Pattern.quote(token) + ".*")) {
-				return true;
-			}
-		}
-		return false;
+		super();
 	}
-
-	public BuiltObject build(UserAgent userAgent, int confidenceTreshold) {
-		Iterator<String> it = simpleTokenMap.keySet().iterator();
-		while (it.hasNext()) {
-			String token = (String) it.next();
-			if (userAgent.getCompleteUserAgent().matches(
-					"(?i).*" + Pattern.quote(token) + ".*")) {
-				String desktopDeviceId = simpleTokenMap.get(token);
-				if (desktopDeviceId != null) {
-					Device device = devices.get(desktopDeviceId);
-					return device;
-				}
-			}
-		}
-		return null;
-	}
-
 }

Modified: devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/DesktopOSDeviceBuilder.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/DesktopOSDeviceBuilder.java?rev=1648964&r1=1648963&r2=1648964&view=diff
==============================================================================
--- devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/DesktopOSDeviceBuilder.java
(original)
+++ devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/DesktopOSDeviceBuilder.java
Fri Jan  2 00:38:43 2015
@@ -18,68 +18,9 @@
  */
 package org.apache.devicemap.simpleddr.builder.device;
 
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-import org.apache.devicemap.simpleddr.model.device.Device;
-import org.apache.devicemap.simpleddr.model.BuiltObject;
-import org.apache.devicemap.simpleddr.model.UserAgent;
-
-public class DesktopOSDeviceBuilder implements DeviceBuilder {
-
-	private final Map<String, String> simpleTokenMap;
-	private Map<String, Device> devices;
-
+public class DesktopOSDeviceBuilder extends SimpleDeviceBuilder {
+	
 	public DesktopOSDeviceBuilder() {
-		simpleTokenMap = new LinkedHashMap<String, String>();
+		super();
 	}
-
-	public void putDevice(String deviceId, List<String> initProperties) {
-
-		for (String token : initProperties) {
-			simpleTokenMap.put(token, deviceId);
-		}
-	}
-
-	public void completeInit(Map<String, Device> devices) {
-		this.devices = devices;
-
-		for (String deviceID : simpleTokenMap.values()) {
-			if (!devices.containsKey(deviceID)) {
-				throw new IllegalStateException(
-						"unable to find device with id: " + deviceID
-								+ "in devices");
-			}
-		}
-	}
-
-	public boolean canBuild(UserAgent userAgent) {
-		for (String token : simpleTokenMap.keySet()) {
-			if (userAgent.getCompleteUserAgent().matches(
-					"(?i).*" + Pattern.quote(token) + ".*")) {
-				return true;
-			}
-		}
-		return false;
-	}
-
-	public BuiltObject build(UserAgent userAgent, int confidenceTreshold) {
-		Iterator<String> it = simpleTokenMap.keySet().iterator();
-		while (it.hasNext()) {
-			String token = (String) it.next();
-			if (userAgent.getCompleteUserAgent().matches(
-					"(?i).*" + Pattern.quote(token) + ".*")) {
-				String desktopDeviceId = simpleTokenMap.get(token);
-				if (desktopDeviceId != null) {
-					Device device = devices.get(desktopDeviceId);
-					return device;
-				}
-			}
-		}
-		return null;
-	}
-
 }

Modified: devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/SymbianDeviceBuilder.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/SymbianDeviceBuilder.java?rev=1648964&r1=1648963&r2=1648964&view=diff
==============================================================================
--- devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/SymbianDeviceBuilder.java
(original)
+++ devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/SymbianDeviceBuilder.java
Fri Jan  2 00:38:43 2015
@@ -38,7 +38,6 @@ public class SymbianDeviceBuilder extend
     public boolean canBuild(UserAgent userAgent) {
         if (userAgent.containsSymbian()) {
             return true;
-
         } else {
             return false;
         }
@@ -46,9 +45,9 @@ public class SymbianDeviceBuilder extend
 
     public Device build(UserAgent userAgent, int confidenceTreshold) {
         ArrayList<Device> foundDevices = new ArrayList<Device>();
-        Iterator it = orderedRules.keySet().iterator();
+        Iterator<String> it = orderedRules.keySet().iterator();
         while (it.hasNext()) {
-            String token = (String) it.next();
+            String token = it.next();
             Device d = elaborateSymbianDeviceWithToken(userAgent, token);
             if (d != null) {
                 if (d.getConfidence() > confidenceTreshold) {
@@ -81,7 +80,6 @@ public class SymbianDeviceBuilder extend
             String currentToken = token;
 
             String looseToken = token.replaceAll("[ _/-]", ".?");
-
             Pattern loosePattern = Pattern.compile(".*" + looseToken + ".*");
 
             if (!loosePattern.matcher(userAgent.getCompleteUserAgent()).matches()) {
@@ -113,7 +111,7 @@ public class SymbianDeviceBuilder extend
                 if (userAgent.getPatternElementsPre() != null && currentPattern.matcher(userAgent.getPatternElementsPre()).matches())
{//userAgent.getPatternElementsPre().matches(".*" + currentToken)) {
                     String deviceId = (String) orderedRules.get(originalToken);
 
-		    if (devices.containsKey(deviceId)) {
+                    if (devices.containsKey(deviceId)) {
                         Device retDevice = (Device) devices.get(deviceId).clone();
                         retDevice.setConfidence(95 - subtract);
                         return retDevice;
@@ -123,7 +121,7 @@ public class SymbianDeviceBuilder extend
                 if (userAgent.getPatternElementsInside() != null && currentPattern.matcher(userAgent.getPatternElementsInside()).matches())
{//userAgent.getPatternElementsInside().matches(".*" + currentToken)) {
                     String deviceId = (String) orderedRules.get(originalToken);
 
-		    if (devices.containsKey(deviceId)) {
+                    if (devices.containsKey(deviceId)) {
                         Device retDevice = (Device) devices.get(deviceId).clone();
                         retDevice.setConfidence(90 - subtract);
                         return retDevice;
@@ -134,7 +132,7 @@ public class SymbianDeviceBuilder extend
                 if (userAgent.getPatternElementsInside() != null && currentPattern.matcher(userAgent.getPatternElementsInside()).matches())
{//userAgent.getPatternElementsInside().matches(".*" + currentToken + ".?;.*")) {
                     String deviceId = (String) orderedRules.get(originalToken);
 
-		    if (devices.containsKey(deviceId)) {
+                    if (devices.containsKey(deviceId)) {
                         Device retDevice = (Device) devices.get(deviceId).clone();
                         retDevice.setConfidence(90 - subtract);
                         return retDevice;
@@ -143,7 +141,6 @@ public class SymbianDeviceBuilder extend
 
                 if (i == 1) {
                     currentPattern = loosePattern;
-
                 } else {
                     currentPattern = Pattern.compile(".*" + currentToken + ".*");
                 }
@@ -151,7 +148,7 @@ public class SymbianDeviceBuilder extend
                 if (userAgent.getPatternElementsInside() != null && currentPattern.matcher(userAgent.getPatternElementsInside()).matches())
{//userAgent.getPatternElementsInside().matches(".*" + currentToken + ".*")) {
                     String deviceId = (String) orderedRules.get(originalToken);
 
-		    if (devices.containsKey(deviceId)) {
+                    if (devices.containsKey(deviceId)) {
                         Device retDevice = (Device) devices.get(deviceId).clone();
                         retDevice.setConfidence(80 - subtract);
                         return retDevice;
@@ -161,7 +158,7 @@ public class SymbianDeviceBuilder extend
                 if (userAgent.getPatternElementsPre() != null && currentPattern.matcher(userAgent.getPatternElementsPre()).matches())
{//userAgent.getPatternElementsPre().matches(".*" + currentToken + ".*")) {
                     String deviceId = (String) orderedRules.get(originalToken);
 
-		    if (devices.containsKey(deviceId)) {
+                    if (devices.containsKey(deviceId)) {
                         Device retDevice = (Device) devices.get(deviceId).clone();
                         retDevice.setConfidence(80 - subtract);
                         return retDevice;
@@ -171,7 +168,7 @@ public class SymbianDeviceBuilder extend
                 if (userAgent.getPatternElementsPost() != null && currentPattern.matcher(userAgent.getPatternElementsPost()).matches())
{//userAgent.getPatternElementsPost().matches(".*" + currentToken + ".*")) {
                     String deviceId = (String) orderedRules.get(originalToken);
 
-		    if (devices.containsKey(deviceId)) {
+                    if (devices.containsKey(deviceId)) {
                         Device retDevice = (Device) devices.get(deviceId).clone();
                         retDevice.setConfidence(60 - subtract);
                         return retDevice;
@@ -209,7 +206,6 @@ public class SymbianDeviceBuilder extend
                         return retDevice;
                     }
                 }
-
                 subtract += 20;
             }
         }

Modified: devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/TwoStepDeviceBuilder.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/TwoStepDeviceBuilder.java?rev=1648964&r1=1648963&r2=1648964&view=diff
==============================================================================
--- devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/TwoStepDeviceBuilder.java
(original)
+++ devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/TwoStepDeviceBuilder.java
Fri Jan  2 00:38:43 2015
@@ -47,7 +47,7 @@ public class TwoStepDeviceBuilder extend
     }
 
     public Device build(UserAgent userAgent, int confidenceTreshold) {
-        ArrayList<Device> foundDevices = new ArrayList<Device>();
+        final List<Device> foundDevices = new ArrayList<Device>();
         for (String step1Token : orderedRules.keySet()) {
             if (userAgent.getCompleteUserAgent().matches("(?i).*" + step1Token + ".*")) {
                 Map<String, String> step1Compliant = (Map<String, String>) orderedRules.get(step1Token);
@@ -146,7 +146,6 @@ public class TwoStepDeviceBuilder extend
                     if (!betweenTokens.matches("[ _/-]?")) {
                         confidence -= 20;
                     }
-
                 } else {
                     confidence -= 40;
                 }

Modified: devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/WinPhoneDeviceBuilder.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/WinPhoneDeviceBuilder.java?rev=1648964&r1=1648963&r2=1648964&view=diff
==============================================================================
--- devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/WinPhoneDeviceBuilder.java
(original)
+++ devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/WinPhoneDeviceBuilder.java
Fri Jan  2 00:38:43 2015
@@ -46,9 +46,9 @@ public class WinPhoneDeviceBuilder exten
 
     public Device build(UserAgent userAgent, int confidenceTreshold) {
         ArrayList<Device> foundDevices = new ArrayList<Device>();
-        Iterator it = orderedRules.keySet().iterator();
+        Iterator<String> it = orderedRules.keySet().iterator();
         while (it.hasNext()) {
-            String token = (String) it.next();
+            String token = it.next();
             Device d = elaborateWinPhoneDeviceWithToken(userAgent, token);
             if (d != null) {
                 if (d.getConfidence() > confidenceTreshold) {
@@ -78,7 +78,6 @@ public class WinPhoneDeviceBuilder exten
             String currentToken = token;
 
             String looseToken = token.replaceAll("[ _/-]", ".?");
-
             Pattern loosePattern = Pattern.compile("(?i).*" + looseToken + ".*");
 
             if (!loosePattern.matcher(userAgent.getCompleteUserAgent()).matches()) {
@@ -100,7 +99,7 @@ public class WinPhoneDeviceBuilder exten
                 if (userAgent.getPatternElementsInside() != null && currentPattern.matcher(userAgent.getPatternElementsInside()).matches())
{
                     String deviceId = (String) orderedRules.get(token);
 
-		    if (devices.containsKey(deviceId)) {
+                    if (devices.containsKey(deviceId)) {
                         Device retDevice = (Device) devices.get(deviceId).clone();
                         retDevice.setConfidence(100 - subtract);
                         return retDevice;
@@ -109,7 +108,7 @@ public class WinPhoneDeviceBuilder exten
                 if (userAgent.getPatternElementsPre() != null && currentPattern.matcher(userAgent.getPatternElementsPre()).matches())
{
                     String deviceId = (String) orderedRules.get(token);
 
-		    if (devices.containsKey(deviceId)) {
+                    if (devices.containsKey(deviceId)) {
                         Device retDevice = (Device) devices.get(deviceId).clone();
                         retDevice.setConfidence(95 - subtract);
                         return retDevice;
@@ -120,7 +119,7 @@ public class WinPhoneDeviceBuilder exten
                 if (userAgent.getPatternElementsInside() != null && currentPattern.matcher(userAgent.getPatternElementsInside()).matches())
{
                     String deviceId = (String) orderedRules.get(token);
 
-		    if (devices.containsKey(deviceId)) {
+                    if (devices.containsKey(deviceId)) {
                         Device retDevice = (Device) devices.get(deviceId).clone();
                         retDevice.setConfidence(90 - subtract);
                         return retDevice;
@@ -129,7 +128,6 @@ public class WinPhoneDeviceBuilder exten
 
                 if (i == 1) {
                     currentPattern = loosePattern;
-
                 } else {
                     currentPattern = Pattern.compile("(?i).*" + currentToken + ".*");
                 }
@@ -137,7 +135,7 @@ public class WinPhoneDeviceBuilder exten
                 if (userAgent.getPatternElementsInside() != null && currentPattern.matcher(userAgent.getPatternElementsInside()).matches())
{
                     String deviceId = (String) orderedRules.get(token);
 
-		    if (devices.containsKey(deviceId)) {
+                    if (devices.containsKey(deviceId)) {
                         Device retDevice = (Device) devices.get(deviceId).clone();
                         retDevice.setConfidence(80 - subtract);
                         return retDevice;
@@ -146,7 +144,7 @@ public class WinPhoneDeviceBuilder exten
                 if (userAgent.getPatternElementsPre() != null && currentPattern.matcher(userAgent.getPatternElementsPre()).matches())
{
                     String deviceId = (String) orderedRules.get(token);
 
-		    if (devices.containsKey(deviceId)) {
+                    if (devices.containsKey(deviceId)) {
                         Device retDevice = (Device) devices.get(deviceId).clone();
                         retDevice.setConfidence(80 - subtract);
                         return retDevice;
@@ -155,7 +153,7 @@ public class WinPhoneDeviceBuilder exten
                 if (userAgent.getPatternElementsPost() != null && currentPattern.matcher(userAgent.getPatternElementsPost()).matches())
{
                     String deviceId = (String) orderedRules.get(token);
 
-		    if (devices.containsKey(deviceId)) {
+                    if (devices.containsKey(deviceId)) {
                         Device retDevice = (Device) devices.get(deviceId).clone();
                         retDevice.setConfidence(60 - subtract);
                         return retDevice;



Mime
View raw message