devicemap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wk...@apache.org
Subject svn commit: r1749105 - in /devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap: DeviceFixer.java DeviceHints.java DeviceMapClient.java data/Device.java data/DeviceType.java data/Pattern.java data/PatternSet.java data/UserAgent.java
Date Sat, 18 Jun 2016 23:03:39 GMT
Author: wkeil
Date: Sat Jun 18 23:03:38 2016
New Revision: 1749105

URL: http://svn.apache.org/viewvc?rev=1749105&view=rev
Log:
DMAP-166: New device: Sony Xperia E1 

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

Added:
    devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/DeviceFixer.java
Modified:
    devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/DeviceHints.java
    devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/DeviceMapClient.java
    devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/Device.java
    devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/DeviceType.java
    devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/Pattern.java
    devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/PatternSet.java
    devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/UserAgent.java

Added: devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/DeviceFixer.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/DeviceFixer.java?rev=1749105&view=auto
==============================================================================
--- devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/DeviceFixer.java
(added)
+++ devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/DeviceFixer.java
Sat Jun 18 23:03:38 2016
@@ -0,0 +1,137 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+package org.apache.devicemap;
+
+import static org.apache.devicemap.data.UserAgent.ANDROID;
+import static org.apache.devicemap.data.UserAgent.WINDOWS;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import org.apache.devicemap.data.DeviceType;
+import org.apache.devicemap.data.UserAgent;
+
+/**
+ * @author Werner Keil
+ * @version 0.1
+ */
+abstract class DeviceFixer {
+	private static final Logger LOG = Logger.getLogger(DeviceFixer.class
+			.getName());
+
+	private static final String DEVICE_OS = "device_os";
+	private static final String DEVICE_OS_VERSION = "device_os_version";
+//	private static final String VENDOR = "vendor";
+	private static final String LIKE_MAC = "like Mac OS X";
+
+	static final DeviceType fixFromUserAgent(final DeviceType device,
+			final UserAgent userAgent) {
+		String pattern = userAgent.getPatternElementsInside();
+		if (pattern != null && pattern.contains(";")) {
+			Map<String, String> attributes;
+			if (device.isLocked()) {
+				// clone map
+				attributes = new HashMap<String, String>();
+
+				attributes.putAll(device.getAttributes());
+			} else {
+				attributes = device.getAttributes();
+			}
+			String[] parts = pattern.split(";");
+
+			for (String part : parts) {
+				if (part != null) {
+					if (part.trim().startsWith(ANDROID)) {
+						final String versionPart = part.trim()
+								.substring(ANDROID.length()).trim();
+						final String versionExisting = attributes
+								.get(DEVICE_OS_VERSION);
+						if (!versionPart.equals(versionExisting)) {
+							LOG.fine("Fixing '" + versionExisting + "' to '"
+									+ versionPart + "'");
+							attributes.put(DEVICE_OS_VERSION, versionPart);
+							device.setAttributes(attributes);
+						}
+					}
+					if (part.trim().endsWith(LIKE_MAC)) {
+						final String versionCandidate = part
+								.trim().substring(0, 
+								part.trim().length() - LIKE_MAC.length()).trim();
+						if (versionCandidate.contains("OS")) {
+							final String versionPart = versionCandidate
+									.substring(
+											versionCandidate.indexOf("OS") + 2)
+									.trim().replaceAll("_", ".");
+							final String versionExisting = attributes
+									.get(DEVICE_OS_VERSION);
+							if (!versionPart.equals(versionExisting)) {
+								LOG.fine("Fixing '" + versionExisting
+										+ "' to '" + versionPart + "'");
+								attributes.put(DEVICE_OS_VERSION, versionPart);
+								device.setAttributes(attributes);
+							}
+						}
+					}
+					if (part.trim().startsWith(WINDOWS)) {
+						final String versionCandidate = part.trim();
+						DeviceHints.WindowsVersion version = DeviceHints.WindowsVersion
+								.ofToken(versionCandidate);
+						if (version != null) {
+							final String osExisting = attributes.get(DEVICE_OS);
+							LOG.fine("Fixing '" + osExisting + "' to '"
+									+ version.getDescription() + "'");
+							attributes.put(DEVICE_OS, version.getDescription());
+							final String versionExisting = attributes
+									.get(DEVICE_OS_VERSION);
+							if (!version.getVersion().equals(versionExisting)) {
+								LOG.fine("Fixing '" + versionExisting
+										+ "' to '" + version.getVersion() + "'");
+								attributes.put(DEVICE_OS_VERSION,
+										version.getVersion());
+							}
+							// final String vendorExisting =
+							// attributes.get(VENDOR);
+							// if (vendorExisting == null ||
+							// vendorExisting.length()==0 ||
+							// "-".equals(vendorExisting) ) {
+							// LOG.finer("Desktop" +
+							// attributes.get("is_desktop"));
+							// if
+							// (Boolean.parseBoolean(attributes.get("is_desktop")))
+							// {
+							// attributes.put(VENDOR, "Microsoft");
+							// }
+							// }
+							device.setAttributes(attributes);
+						}
+					} /*
+					 * else { String versionCandidate = part.trim();
+					 * System.out.println(versionCandidate); }
+					 */
+				}
+			}
+		}
+		
+		
+		// logger.info("Device: " + device.getId() + " - " +
+		// device.getPropertiesMap());
+		return device;
+	}
+}

Modified: devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/DeviceHints.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/DeviceHints.java?rev=1749105&r1=1749104&r2=1749105&view=diff
==============================================================================
--- devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/DeviceHints.java
(original)
+++ devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/DeviceHints.java
Sat Jun 18 23:03:38 2016
@@ -18,6 +18,10 @@
  */
 package org.apache.devicemap;
 
+/**
+ * @author Werner Keil
+ * @version 0.2
+ */
 abstract class DeviceHints {
 	static enum WindowsVersion {
 		WIN_81("Windows NT 6.3"	,"Windows 8.1", "8.1"),

Modified: devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/DeviceMapClient.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/DeviceMapClient.java?rev=1749105&r1=1749104&r2=1749105&view=diff
==============================================================================
--- devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/DeviceMapClient.java
(original)
+++ devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/DeviceMapClient.java
Sat Jun 18 23:03:38 2016
@@ -18,8 +18,7 @@
  */
 package org.apache.devicemap;
 
-import static org.apache.devicemap.data.UserAgent.ANDROID;
-import static org.apache.devicemap.data.UserAgent.WINDOWS;
+import static org.apache.devicemap.DeviceFixer.fixFromUserAgent;
 
 import java.io.IOException;
 import java.util.*;
@@ -35,245 +34,187 @@ import org.apache.devicemap.loader.Loade
 
 /**
  * @author Werner Keil
- * @version 1.0.11
+ * @version 1.0.12
  */
 public class DeviceMapClient {
-    private static final Logger LOG = Logger.getLogger(DeviceMapClient.class.getName());
-    private static final java.util.regex.Pattern TEXT_SPLIT_PATTERN = java.util.regex.Pattern.compile("
|-|_|/|\\\\|\\[|\\]|\\(|\\)|;");
+	private static final Logger LOG = Logger.getLogger(DeviceMapClient.class
+			.getName());
+	private static final java.util.regex.Pattern TEXT_SPLIT_PATTERN = java.util.regex.Pattern
+			.compile(" |-|_|/|\\\\|\\[|\\]|\\(|\\)|;");
+
+	private static long initCount = 0;
+
+	// indexes
+	private Map<String, DeviceType> devices;
+	private Map<String, List<DeviceType>> patterns;
+
+	private final Device unknown;
+
+	public DeviceMapClient() {
+		devices = null;
+		patterns = null;
+		Map<String, String> uAttributes = new HashMap<String, String>();
+		uAttributes.put("id", Device.UNKNOWN_ID);
+		uAttributes = Collections.unmodifiableMap(uAttributes);
+		unknown = new Device(Device.UNKNOWN_ID, uAttributes);
+	}
+
+	public void initDeviceData(LoaderOption option) throws IOException {
+		initDeviceData(option, null);
+	}
+
+	public synchronized void initDeviceData(LoaderOption option, String path)
+			throws IOException {
+		devices = LoaderFactory.getLoader(option, path).getData();
+		initCount++;
+
+		if (initCount % 1000 == 0) {
+			LOG.log(Level.WARNING,
+					"Possible device data over-initialization detected");
+		}
+
+		if (devices == null) {
+			patterns = null;
+			return;
+		}
+		createIndex();
+	}
 
-    private static long initCount = 0;
+	private void createIndex() {
+		patterns = new HashMap<String, List<DeviceType>>(8000);
 
-    //indexes
-    private Map<String, DeviceType> devices;
-    private Map<String, List<DeviceType>> patterns;
-
-    private final Device unknown;
-
-    public DeviceMapClient() {
-        devices = null;
-        patterns = null;
-        Map<String, String> uAttributes = new HashMap<String, String>();
-        uAttributes.put("id", Device.UNKNOWN_ID);
-        uAttributes = Collections.unmodifiableMap(uAttributes);
-        unknown = new Device(Device.UNKNOWN_ID, uAttributes);
-    }
-
-    public void initDeviceData(LoaderOption option) throws IOException {
-        initDeviceData(option, null);
-    }
-
-    public synchronized void initDeviceData(LoaderOption option, String path) throws IOException
{
-        devices = LoaderFactory.getLoader(option, path).getData();
-        initCount++;
-
-        if (initCount % 1000 == 0) {
-            LOG.log(Level.WARNING, "Possible device data over-initialization detected");
-        }
-
-        if (devices == null) {
-            patterns = null;
-            return;
-        }
-        createIndex();
-    }
-
-    private void createIndex() {
-        patterns = new HashMap<String, List<DeviceType>>(8000);
-
-        for (DeviceType device : devices.values()) {
-            for (Pattern pattern : device.getPatternSet().getPatterns()) {
-                for (int i = 0; i < pattern.getPatternParts().size(); i++) {
-                    String part = pattern.getPatternParts().get(i);
-
-                    //duplicate
-                    if (patterns.get(part) != null) {
-                        if (i == (pattern.getPatternParts().size() - 1) && !patterns.get(part).contains(device))
{
-                            patterns.get(part).add(device);
-                        }
-                    } else {
-                        List<DeviceType> single = new ArrayList<DeviceType>();
-                        single.add(device);
-                        patterns.put(part, single);
-                    }
-                }
-            }
-        }
-    }
-
-    public Map<String, String> classify(String text) {
-        if (devices == null) {
-            throw new RuntimeException("Uninitialized device index");
-        }
-
-        if (text == null) {
-            return null;
-        }
-
-        Set<String> hitPatterns = new HashSet<String>();
-        Set<DeviceType> hitDevices = new HashSet<DeviceType>();
-        DeviceType winner = null;
-        Pattern winnerPattern = null;
-        LOG.log(Level.FINE, "classify: ''{0}''", text);
-        List<String> parts = split(text);
-
-        //generate ngrams upto size 4
-        for (int i = 0; i < parts.size(); i++) {
-            String pattern = "";
-            for (int j = 0; j < 4 && (j + i) < parts.size(); j++) {
-                pattern += parts.get(i + j);
-                List<DeviceType> dlist = patterns.get(pattern);
-                if (dlist != null) {
-                    hitPatterns.add(pattern);
-                    hitDevices.addAll(dlist);
-                    for (DeviceType device : dlist) {
-                        LOG.log(Level.FINER, "Hit found: ''{0}'' => id: ''{1}'' {2}",
new Object[]{pattern, device.getId(), device.getPatternSet()});
-                    }
-                }
-            }
-        }
-
-        //look for the strongest hit
-        for (DeviceType device : hitDevices) {
-            Pattern pattern = device.getPatternSet().isValid(hitPatterns);
-            if (pattern == null) {
-                continue;
-            }
-
-            LOG.log(Level.FINER, "Hit candidate: ''{0}'' => ({1},{2})", new Object[]{device.getId(),
pattern.getType(), pattern.getRank()});
-
-            if (winnerPattern == null || pattern.getRank() > winnerPattern.getRank())
{
-                winner = device;
-                winnerPattern = pattern;
-            }
-        }
-
-        if (winner != null) {
-            LOG.log(Level.FINE, "Result: {0}", winner);
-            
-            UserAgent userAgent = UserAgent.of(text);
-            LOG.log(Level.FINE, "User Agent: {0}", userAgent);
-            //fixFromUserAgent(winner, userAgent);
-            return fixFromUserAgent(winner, userAgent).getAttributes();
-        } else {
-            return null;
-        }
-    }
-
-    private static final String DEVICE_OS = "device_os";
-    private static final String DEVICE_OS_VERSION = "device_os_version";
-    private static final String VENDOR = "vendor";
-    private static final String LIKE_MAC = "like Mac OS X";
-    
-    private DeviceType fixFromUserAgent(final DeviceType device, final UserAgent userAgent)
{
-		String pattern = userAgent.getPatternElementsInside();
-		if (pattern != null && pattern.contains(";")) {
-	    	Map<String, String> attributes;
-	    	if (device.isLocked()) {
-	    		// clone map
-			   attributes = new HashMap<String, String>();
-		
-			   attributes.putAll(device.getAttributes());
-	    	} else {
-	    		attributes = device.getAttributes();
-	    	}
-			String[] parts = pattern.split(";");
-		
-			for (String part : parts) {
-				if (part != null) {
-					if (part.trim().startsWith(ANDROID)) {
-						final String versionPart = part.trim().substring(ANDROID.length()).trim();
-						final String versionExisting = attributes.get(DEVICE_OS_VERSION);
-						if (!versionPart.equals(versionExisting)) {
-							LOG.fine("Fixing '" + versionExisting +"' to '" + versionPart + "'" );
-							attributes.put(DEVICE_OS_VERSION, versionPart);
-							device.setAttributes(attributes);
+		for (DeviceType device : devices.values()) {
+			for (Pattern pattern : device.getPatternSet().getPatterns()) {
+				for (int i = 0; i < pattern.getPatternParts().size(); i++) {
+					String part = pattern.getPatternParts().get(i);
+
+					// duplicate
+					if (patterns.get(part) != null) {
+						if (i == (pattern.getPatternParts().size() - 1)
+								&& !patterns.get(part).contains(device)) {
+							patterns.get(part).add(device);
 						}
+					} else {
+						List<DeviceType> single = new ArrayList<DeviceType>();
+						single.add(device);
+						patterns.put(part, single);
 					}
-					if (part.trim().endsWith(LIKE_MAC)) {
-						final String versionCandidate = part.trim().substring(0, part.trim().length() - LIKE_MAC.length()).trim();
-						if (versionCandidate.contains("OS")) {
-							final String versionPart = versionCandidate.substring(versionCandidate.indexOf("OS")+2).trim().replaceAll("_",
".");
-							final String versionExisting = attributes.get(DEVICE_OS_VERSION);
-							if (!versionPart.equals(versionExisting)) {
-								LOG.fine("Fixing '" + versionExisting +"' to '" + versionPart + "'" );
-								attributes.put(DEVICE_OS_VERSION, versionPart);
-								device.setAttributes(attributes);
-							}
-						}
+				}
+			}
+		}
+	}
+
+	public Map<String, String> classify(String text) {
+		if (devices == null) {
+			throw new RuntimeException("Uninitialized device index");
+		}
+
+		if (text == null) {
+			return null;
+		}
+
+		Set<String> hitPatterns = new HashSet<String>();
+		Set<DeviceType> hitDevices = new HashSet<DeviceType>();
+		DeviceType winner = null;
+		Pattern winnerPattern = null;
+		LOG.log(Level.FINE, "classify: ''{0}''", text);
+		List<String> parts = split(text);
+
+		// generate ngrams upto size 4
+		for (int i = 0; i < parts.size(); i++) {
+			String pattern = "";
+			for (int j = 0; j < 4 && (j + i) < parts.size(); j++) {
+				pattern += parts.get(i + j);
+				List<DeviceType> dlist = patterns.get(pattern);
+				if (dlist != null) {
+					hitPatterns.add(pattern);
+					hitDevices.addAll(dlist);
+					for (DeviceType device : dlist) {
+						LOG.log(Level.FINER,
+								"Hit found: ''{0}'' => id: ''{1}'' {2}",
+								new Object[] { pattern, device.getId(),
+										device.getPatternSet() });
 					}
-					if (part.trim().startsWith(WINDOWS)) {
-						final String versionCandidate = part.trim();
-						DeviceHints.WindowsVersion version = DeviceHints.WindowsVersion.ofToken(versionCandidate);
-						if (version != null) {
-							final String osExisting = attributes.get(DEVICE_OS);
-							LOG.fine("Fixing '" + osExisting +"' to '" + version.getDescription() + "'" );
-							attributes.put(DEVICE_OS, version.getDescription());
-							final String versionExisting = attributes.get(DEVICE_OS_VERSION);
-							if (!version.getVersion().equals(versionExisting)) {
-								LOG.fine("Fixing '" + versionExisting +"' to '" + version.getVersion() + "'" );
-								attributes.put(DEVICE_OS_VERSION, version.getVersion());
-							}
-//							final String vendorExisting = attributes.get(VENDOR);
-//							if (vendorExisting == null || vendorExisting.length()==0 || "-".equals(vendorExisting)
) {
-//								LOG.finer("Desktop" + attributes.get("is_desktop"));
-//								if (Boolean.parseBoolean(attributes.get("is_desktop"))) {
-//									attributes.put(VENDOR, "Microsoft");
-//								}
-//							}
-							device.setAttributes(attributes);
-						}
-					} /* else {
-						String versionCandidate = part.trim();
-						System.out.println(versionCandidate);
-					} */
 				}
 			}
 		}
-//    	logger.info("Device: " + device.getId() + " - " + device.getPropertiesMap());
-    	return device;
-    }
-    
-    private static List<String> split(String text) {
-        String[] parts = TEXT_SPLIT_PATTERN.split(text);
-        List<String> nonemptyParts = new ArrayList<String>();
-        for (String part : parts) {
-            String normalizedPart = Pattern.normalize(part);
-            if (normalizedPart != null && !normalizedPart.isEmpty())
-                nonemptyParts.add(normalizedPart);
-        }
-        return nonemptyParts;
-    }
-
-    public Device classifyDevice(String text) {
-        Map<String, String> m = classify(text);
-        if (m == null) {
-            return unknown;
-        }
-        return new Device(m.get("id"), m);
-    }
-
-    public int getDeviceCount() {
-        if (devices == null) {
-            return -1;
-        }
-        return devices.size();
-    }
-
-    public int getPatternCount() {
-        if (patterns == null) {
-            return -1;
-        }
-        return patterns.size();
-    }
-
-    public long getNodeCount() {
-        if (patterns == null) {
-            return -1;
-        }
-        long count = 0;
-        for (List<DeviceType> pDevices : patterns.values()) {
-            count += pDevices.size();
-        }
-        return count;
-    }
+
+		// look for the strongest hit
+		for (DeviceType device : hitDevices) {
+			Pattern pattern = device.getPatternSet().isValid(hitPatterns);
+			if (pattern == null) {
+				continue;
+			}
+
+			LOG.log(Level.FINER,
+					"Hit candidate: ''{0}'' => ({1},{2})",
+					new Object[] { device.getId(), pattern.getType(),
+							pattern.getRank() });
+
+			if (winnerPattern == null
+					|| pattern.getRank() > winnerPattern.getRank()) {
+				winner = device;
+				winnerPattern = pattern;
+			}
+		}
+
+		if (winner != null) {
+			LOG.log(Level.FINE, "Result: {0}", winner);
+
+			UserAgent userAgent = UserAgent.of(text);
+			LOG.log(Level.FINE, "User Agent: {0}", userAgent);
+			// fixFromUserAgent(winner, userAgent);
+			return fixFromUserAgent(winner, userAgent).getAttributes();
+		} else {
+			return null;
+		}
+	}
+
+	private static List<String> split(String text) {
+		String[] parts = TEXT_SPLIT_PATTERN.split(text);
+		List<String> nonemptyParts = new ArrayList<String>();
+		for (String part : parts) {
+			String normalizedPart = Pattern.normalize(part);
+			if (normalizedPart != null && !normalizedPart.isEmpty())
+				nonemptyParts.add(normalizedPart);
+		}
+		return nonemptyParts;
+	}
+
+	public Device classifyDevice(String text) {
+		Map<String, String> m = classify(text);
+		if (m == null) {
+			return unknown;
+		}
+		return new Device(m.get("id"), m);
+	}
+
+	public int getDeviceCount() {
+		if (devices == null) {
+			return -1;
+		}
+		return devices.size();
+	}
+
+	public int getPatternCount() {
+		if (patterns == null) {
+			return -1;
+		}
+		return patterns.size();
+	}
+
+	public long getNodeCount() {
+		if (patterns == null) {
+			return -1;
+		}
+		long count = 0;
+		for (List<DeviceType> pDevices : patterns.values()) {
+			count += pDevices.size();
+		}
+		return count;
+	}
+
+	Map<String, DeviceType> getDevices() {
+		return devices;
+	}
 }

Modified: devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/Device.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/Device.java?rev=1749105&r1=1749104&r2=1749105&view=diff
==============================================================================
--- devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/Device.java
(original)
+++ devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/Device.java
Sat Jun 18 23:03:38 2016
@@ -21,12 +21,15 @@ package org.apache.devicemap.data;
 import java.util.Map;
 import org.apache.devicemap.loader.parser.JsonParser;
 
+/**
+ * @author Reza
+ * @author Werner Keil
+ * @version 1.1
+ */
 public class Device {
-    
     public static final String UNKNOWN_ID = "unknown";
-    
-    private final String id;
 
+    private final String id;
     private final Map<String, String> attributes;
     
     public Device(String id, Map<String, String> attributes) {

Modified: devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/DeviceType.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/DeviceType.java?rev=1749105&r1=1749104&r2=1749105&view=diff
==============================================================================
--- devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/DeviceType.java
(original)
+++ devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/DeviceType.java
Sat Jun 18 23:03:38 2016
@@ -22,16 +22,16 @@ import java.util.Collections;
 import java.util.Map;
 import org.apache.devicemap.loader.parser.JsonParser;
 
+/**
+ * @author Werner Keil
+ * @version 1.1
+ */
 public class DeviceType {
 
     private String id;
-
     private String parentId;
-
     private final PatternSet pattern;
-
     private Map<String, String> attributes;
-
     private boolean locked;
     
     public DeviceType() {

Modified: devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/Pattern.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/Pattern.java?rev=1749105&r1=1749104&r2=1749105&view=diff
==============================================================================
--- devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/Pattern.java
(original)
+++ devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/Pattern.java
Sat Jun 18 23:03:38 2016
@@ -23,14 +23,14 @@ import java.util.List;
 import java.util.Set;
 import org.apache.devicemap.loader.parser.JsonParser;
 
+/**
+ * @author Werner Keil
+ * @version 1.1
+ */
 public class Pattern {
-
     private final List<String> pattern;
-
     private final String type;
-    
     private final int rank;
-    
     private final int boost;
 
     public Pattern(String pattern, String type, int boost) {
@@ -70,7 +70,6 @@ public class Pattern {
         for (String part : pattern) {
             r += part.length();
         }
-        
         return r;
     }
     
@@ -104,10 +103,8 @@ public class Pattern {
         }
 
         p = p.toLowerCase().trim();
-
         p = p.replaceAll("\\[bb\\]", "b");
-
-        StringBuilder ret = new StringBuilder();
+        final StringBuilder ret = new StringBuilder();
 
         for (int i = 0; i < p.length(); i++) {
             Character c = p.charAt(i);

Modified: devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/PatternSet.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/PatternSet.java?rev=1749105&r1=1749104&r2=1749105&view=diff
==============================================================================
--- devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/PatternSet.java
(original)
+++ devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/PatternSet.java
Sat Jun 18 23:03:38 2016
@@ -23,8 +23,11 @@ import java.util.List;
 import java.util.Set;
 import org.apache.devicemap.loader.parser.JsonParser;
 
+/**
+ * @author Werner Keil
+ * @version 1.1
+ */
 public class PatternSet {
-
     private final List<Pattern> patterns;
 
     public PatternSet() {

Modified: devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/UserAgent.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/UserAgent.java?rev=1749105&r1=1749104&r2=1749105&view=diff
==============================================================================
--- devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/UserAgent.java
(original)
+++ devicemap/trunk/clients/1.0/java/client/src/main/java/org/apache/devicemap/data/UserAgent.java
Sat Jun 18 23:03:38 2016
@@ -21,6 +21,10 @@ package org.apache.devicemap.data;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+/**
+ * @author Werner Keil
+ * @version 0.3
+ */
 public class UserAgent {
 	public static final String ANDROID = "Android";
 	public static final String WINDOWS = "Windows";
@@ -35,7 +39,7 @@ public class UserAgent {
 	Pattern.compile(MOZILLA_AND_OPERA_PATTERN);
     private static Pattern versionPatternCompiled =
 	Pattern.compile(".*Version/(\\d+.\\d+).*");
-    private String completeUserAgent;
+    private final String completeUserAgent;
     private boolean mozillaPattern;
     private boolean operaPattern;
     private String mozillaVersion;
@@ -54,7 +58,7 @@ public class UserAgent {
         }
         completeUserAgent = userAgent;
 
-        Matcher result = mozillaPatternCompiled.matcher(userAgent);
+        final Matcher result = mozillaPatternCompiled.matcher(userAgent);
 
         if (result.matches()) {
             patternElements = new String[]{
@@ -155,7 +159,7 @@ public class UserAgent {
         return containsSymbian;
     }
 
-    public boolean containsWindowsPhone() {
+    public boolean containsWindows() {
         return containsWindowsPhone;
     }
 



Mime
View raw message