You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devicemap.apache.org by bd...@apache.org on 2012/10/02 15:32:32 UTC

svn commit: r1392911 [5/7] - in /incubator/devicemap/trunk/openddr: ./ java/ java/src/ java/src/org/ java/src/org/openddr/ java/src/org/openddr/simpleapi/ java/src/org/openddr/simpleapi/oddr/ java/src/org/openddr/simpleapi/oddr/builder/ java/src/org/op...

Added: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/OperaOSModelBuilder.java
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/OperaOSModelBuilder.java?rev=1392911&view=auto
==============================================================================
--- incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/OperaOSModelBuilder.java (added)
+++ incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/OperaOSModelBuilder.java Tue Oct  2 13:32:28 2012
@@ -0,0 +1,79 @@
+/**
+ * Copyright 2011 OpenDDR LLC
+ * This software is distributed under the terms of the GNU Lesser General Public License.
+ *
+ *
+ * This file is part of OpenDDR Simple APIs.
+ * OpenDDR Simple APIs is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OpenDDR Simple APIs is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Simple APIs.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.openddr.simpleapi.oddr.builder.os;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.openddr.simpleapi.oddr.builder.Builder;
+import org.openddr.simpleapi.oddr.builder.device.WinPhoneDeviceBuilder;
+import org.openddr.simpleapi.oddr.builder.os.mozilla.AndroidMozillaSubBuilder;
+import org.openddr.simpleapi.oddr.builder.os.mozilla.SymbianMozillaSubBuilder;
+import org.openddr.simpleapi.oddr.builder.os.mozilla.WinCEMozillaSubBuilder;
+import org.openddr.simpleapi.oddr.model.BuiltObject;
+import org.openddr.simpleapi.oddr.model.UserAgent;
+import org.openddr.simpleapi.oddr.model.os.OperatingSystem;
+
+public class OperaOSModelBuilder implements Builder {
+
+    private Builder[] builders = {
+        new AndroidMozillaSubBuilder(),
+        new SymbianMozillaSubBuilder(),
+        new WinCEMozillaSubBuilder(),
+        new WinPhoneDeviceBuilder()
+    };
+
+    public boolean canBuild(UserAgent userAgent) {
+        if (userAgent.hasOperaPattern()) {
+            return true;
+        }
+        return false;
+    }
+
+    public BuiltObject build(UserAgent userAgent, int confidenceTreshold) {
+        List<OperatingSystem> founds = new ArrayList<OperatingSystem>();
+        OperatingSystem found = null;
+        for (Builder builder : builders) {
+            if (builder.canBuild(userAgent)) {
+                OperatingSystem builded = (OperatingSystem) builder.build(userAgent, confidenceTreshold);
+                if (builded != null) {
+                    founds.add(builded);
+                    if (builded.getConfidence() >= confidenceTreshold) {
+                        found = builded;
+                        break;
+                    }
+                }
+            }
+        }
+
+        if (found != null) {
+            return found;
+
+        } else {
+            if (founds.isEmpty()) {
+                return null;
+            }
+
+            Collections.sort(founds, Collections.reverseOrder());
+            return founds.get(0);
+        }
+    }
+}

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/OperaOSModelBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/OperaOSModelBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/AndroidMozillaSubBuilder.java
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/AndroidMozillaSubBuilder.java?rev=1392911&view=auto
==============================================================================
--- incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/AndroidMozillaSubBuilder.java (added)
+++ incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/AndroidMozillaSubBuilder.java Tue Oct  2 13:32:28 2012
@@ -0,0 +1,98 @@
+/**
+ * Copyright 2011 OpenDDR LLC
+ * This software is distributed under the terms of the GNU Lesser General Public License.
+ *
+ *
+ * This file is part of OpenDDR Simple APIs.
+ * OpenDDR Simple APIs is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OpenDDR Simple APIs is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Simple APIs.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.openddr.simpleapi.oddr.builder.os.mozilla;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.openddr.simpleapi.oddr.builder.Builder;
+import org.openddr.simpleapi.oddr.model.UserAgent;
+import org.openddr.simpleapi.oddr.model.os.OperatingSystem;
+
+public class AndroidMozillaSubBuilder implements Builder {
+
+    private static final String VERSION_REGEXP = ".*?Android.?((\\d+)\\.(\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?(.*))";
+    private static final String BUILD_HASH_REGEXP = ".*Build/(.*)(?:[ \\)])?";
+    private Pattern versionPattern = Pattern.compile(VERSION_REGEXP);
+    private Pattern buildHashPattern = Pattern.compile(BUILD_HASH_REGEXP);
+
+    public boolean canBuild(UserAgent userAgent) {
+        if (userAgent.containsAndroid()) {
+            return true;
+        }
+        return false;
+    }
+
+    public OperatingSystem build(UserAgent userAgent, int confidenceTreshold) {
+        OperatingSystem model = new OperatingSystem();
+        model.setMajorRevision("1");
+        model.setVendor("Google");
+        model.setModel("Android");
+        model.setConfidence(40);
+
+        String[] splittedTokens = userAgent.getPatternElementsInside().split(";");
+        for (String tokenElement : splittedTokens) {
+            Matcher versionMatcher = versionPattern.matcher(tokenElement);
+            if (versionMatcher.find()) {
+                if (model.getConfidence() > 40) {
+                    model.setConfidence(100);
+
+                } else {
+                    model.setConfidence(90);
+                }
+
+                if (versionMatcher.group(1) != null) {
+                    model.setVersion(versionMatcher.group(1));
+                }
+                if (versionMatcher.group(2) != null) {
+                    model.setMajorRevision(versionMatcher.group(2));
+                }
+                if (versionMatcher.group(3) != null) {
+                    model.setMinorRevision(versionMatcher.group(3));
+                }
+                if (versionMatcher.group(4) != null) {
+                    model.setMicroRevision(versionMatcher.group(4));
+                }
+                if (versionMatcher.group(5) != null) {
+                    model.setNanoRevision(versionMatcher.group(5));
+                }
+                if (versionMatcher.group(6) != null) {
+                    model.setDescription(versionMatcher.group(6));
+                }
+            }
+
+            Matcher buildHashMatcher = buildHashPattern.matcher(tokenElement);
+
+            if (buildHashMatcher.find()) {
+                if (model.getConfidence() > 40) {
+                    model.setConfidence(100);
+
+                } else {
+                    model.setConfidence(45);
+                }
+
+                if (buildHashMatcher.group(1) != null) {
+                    model.setBuild(buildHashMatcher.group(1));
+                }
+            }
+        }
+        return model;
+    }
+}

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/AndroidMozillaSubBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/AndroidMozillaSubBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/BadaMozillaSubBuilder.java
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/BadaMozillaSubBuilder.java?rev=1392911&view=auto
==============================================================================
--- incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/BadaMozillaSubBuilder.java (added)
+++ incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/BadaMozillaSubBuilder.java Tue Oct  2 13:32:28 2012
@@ -0,0 +1,72 @@
+/**
+ * Copyright 2011 OpenDDR LLC
+ * This software is distributed under the terms of the GNU Lesser General Public License.
+ *
+ *
+ * This file is part of OpenDDR Simple APIs.
+ * OpenDDR Simple APIs is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OpenDDR Simple APIs is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Simple APIs.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.openddr.simpleapi.oddr.builder.os.mozilla;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.openddr.simpleapi.oddr.builder.Builder;
+import org.openddr.simpleapi.oddr.model.UserAgent;
+import org.openddr.simpleapi.oddr.model.os.OperatingSystem;
+
+public class BadaMozillaSubBuilder implements Builder {
+
+    private static final String VERSION_REGEXP = ".*?Bada.?((\\d+)\\.(\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?(.*))";
+    private Pattern versionPattern = Pattern.compile(VERSION_REGEXP);
+
+    public boolean canBuild(UserAgent userAgent) {
+        if (userAgent.getPatternElementsInside() != null && userAgent.getPatternElementsInside().contains("Bada")) {
+            return true;
+        }
+        return false;
+    }
+
+    public OperatingSystem build(UserAgent userAgent, int confidenceTreshold) {
+        OperatingSystem model = new OperatingSystem();
+        model.setMajorRevision("1");
+        model.setVendor("Samsung");
+        model.setModel("Bada");
+        model.setConfidence(40);
+
+        String[] splittedTokens = userAgent.getPatternElementsInside().split(";");
+        for (String tokenElement : splittedTokens) {
+            Matcher versionMatcher = versionPattern.matcher(tokenElement);
+            if (versionMatcher.find()) {
+                model.setConfidence(90);
+                if (versionMatcher.group(1) != null) {
+                    model.setVersion(versionMatcher.group(1));
+                }
+                if (versionMatcher.group(2) != null) {
+                    model.setMajorRevision(versionMatcher.group(2));
+                }
+                if (versionMatcher.group(3) != null) {
+                    model.setMinorRevision(versionMatcher.group(3));
+                }
+                if (versionMatcher.group(4) != null) {
+                    model.setMicroRevision(versionMatcher.group(4));
+                }
+                if (versionMatcher.group(5) != null) {
+                    model.setNanoRevision(versionMatcher.group(5));
+                }
+            }
+        }
+        return model;
+    }
+}

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/BadaMozillaSubBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/BadaMozillaSubBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/BlackBerryMozillaSubBuilder.java
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/BlackBerryMozillaSubBuilder.java?rev=1392911&view=auto
==============================================================================
--- incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/BlackBerryMozillaSubBuilder.java (added)
+++ incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/BlackBerryMozillaSubBuilder.java Tue Oct  2 13:32:28 2012
@@ -0,0 +1,145 @@
+/**
+ * Copyright 2011 OpenDDR LLC
+ * This software is distributed under the terms of the GNU Lesser General Public License.
+ *
+ *
+ * This file is part of OpenDDR Simple APIs.
+ * OpenDDR Simple APIs is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OpenDDR Simple APIs is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Simple APIs.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.openddr.simpleapi.oddr.builder.os.mozilla;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.openddr.simpleapi.oddr.builder.Builder;
+import org.openddr.simpleapi.oddr.model.UserAgent;
+import org.openddr.simpleapi.oddr.model.os.OperatingSystem;
+
+public class BlackBerryMozillaSubBuilder implements Builder {
+
+    private static final String VERSION_REGEXP = "(?:.*?Version.?((\\d+)\\.(\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?).*)|(?:.*?[Bb]lack.?[Bb]erry(?:\\d+)/((\\d+)\\.(\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?).*)|(?:.*?RIM.?Tablet.?OS.?((\\d+)\\.(\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?).*)";
+    private Pattern versionPattern = Pattern.compile(VERSION_REGEXP);
+
+    public boolean canBuild(UserAgent userAgent) {
+        if (userAgent.containsBlackBerryOrRim()) {
+            return true;
+        }
+        return false;
+    }
+
+    public OperatingSystem build(UserAgent userAgent, int confidenceTreshold) {
+        OperatingSystem model = new OperatingSystem();
+
+        String rebuilded = userAgent.getPatternElementsInside() + ";" + userAgent.getPatternElementsPost();
+
+        String[] splittedTokens = rebuilded.split(";");
+        for (String tokenElement : splittedTokens) {
+            Matcher versionMatcher = versionPattern.matcher(tokenElement);
+            if (versionMatcher.find()) {
+                if (versionMatcher.group(11) != null) {
+                    model.setVendor("Research In Motion");
+                    model.setModel("RIM Tablet OS");
+                    model.setMajorRevision("1");
+                    model.setConfidence(50);
+
+                    if (versionMatcher.group(11) != null) {
+                        model.setVersion(versionMatcher.group(11));
+
+                    }
+
+                    if (versionMatcher.group(12) != null) {
+                        model.setMajorRevision(versionMatcher.group(12));
+                        model.setConfidence(60);
+
+                    }
+
+                    if (versionMatcher.group(13) != null) {
+                        model.setMinorRevision(versionMatcher.group(13));
+                        model.setConfidence(70);
+
+                    }
+
+                    if (versionMatcher.group(14) != null) {
+                        model.setMicroRevision(versionMatcher.group(14));
+                        model.setConfidence(80);
+
+                    }
+
+                    if (versionMatcher.group(15) != null) {
+                        model.setNanoRevision(versionMatcher.group(5));
+                        model.setConfidence(90);
+
+                    }
+                    return model;
+
+                } else if (versionMatcher.group(1) != null || versionMatcher.group(6) != null) {
+                    model.setVendor("Research In Motion");
+                    model.setModel("Black Berry OS");
+                    model.setMajorRevision("1");
+                    model.setConfidence(40);
+
+                    if (versionMatcher.group(1) != null) {
+                        if (versionMatcher.group(6) != null) {
+                            model.setConfidence(100);
+
+                        } else {
+                            model.setConfidence(80);
+                        }
+
+                    } else if (versionMatcher.group(6) != null) {
+                        model.setConfidence(90);
+                    }
+
+                    if (versionMatcher.group(1) != null) {
+                        model.setVersion(versionMatcher.group(1));
+
+                    } else if (versionMatcher.group(6) != null) {
+                        model.setVersion(versionMatcher.group(6));
+                    }
+
+                    if (versionMatcher.group(2) != null) {
+                        model.setMajorRevision(versionMatcher.group(2));
+
+                    } else if (versionMatcher.group(7) != null) {
+                        model.setMajorRevision(versionMatcher.group(7));
+                    }
+
+                    if (versionMatcher.group(3) != null) {
+                        model.setMinorRevision(versionMatcher.group(3));
+
+                    } else if (versionMatcher.group(8) != null) {
+                        model.setMinorRevision(versionMatcher.group(8));
+                    }
+
+                    if (versionMatcher.group(4) != null) {
+                        model.setMicroRevision(versionMatcher.group(4));
+
+                    } else if (versionMatcher.group(9) != null) {
+                        model.setMicroRevision(versionMatcher.group(9));
+                    }
+
+                    if (versionMatcher.group(5) != null) {
+                        model.setNanoRevision(versionMatcher.group(5));
+
+                    } else if (versionMatcher.group(10) != null) {
+                        model.setNanoRevision(versionMatcher.group(10));
+                    }
+                    return model;
+
+                }
+            }
+        }
+        return model;
+    }
+}

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/BlackBerryMozillaSubBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/BlackBerryMozillaSubBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/BrewMozillaSubBuilder.java
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/BrewMozillaSubBuilder.java?rev=1392911&view=auto
==============================================================================
--- incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/BrewMozillaSubBuilder.java (added)
+++ incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/BrewMozillaSubBuilder.java Tue Oct  2 13:32:28 2012
@@ -0,0 +1,74 @@
+/**
+ * Copyright 2011 OpenDDR LLC
+ * This software is distributed under the terms of the GNU Lesser General Public License.
+ *
+ *
+ * This file is part of OpenDDR Simple APIs.
+ * OpenDDR Simple APIs is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OpenDDR Simple APIs is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Simple APIs.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.openddr.simpleapi.oddr.builder.os.mozilla;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.openddr.simpleapi.oddr.builder.Builder;
+import org.openddr.simpleapi.oddr.model.UserAgent;
+import org.openddr.simpleapi.oddr.model.os.OperatingSystem;
+
+public class BrewMozillaSubBuilder implements Builder {
+
+    private static final String VERSION_REGEXP = ".*?(?:(?:Brew|BREW).?(?:MP)?).((\\d+)\\.(\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?(.*))";
+    private Pattern versionPattern = Pattern.compile(VERSION_REGEXP);
+
+    public boolean canBuild(UserAgent userAgent) {
+        if (userAgent.getPatternElementsInside() != null && userAgent.getPatternElementsInside().matches("(?i).*brew.*")) {
+            return true;
+
+        } else {
+            return false;
+        }
+    }
+
+    public OperatingSystem build(UserAgent userAgent, int confidenceTreshold) {
+        OperatingSystem model = new OperatingSystem();
+        model.setMajorRevision("1");
+        model.setVendor("Qualcomm");
+        model.setModel("Brew");
+        model.setConfidence(40);
+
+        String[] splittedTokens = userAgent.getPatternElementsInside().split(";");
+        for (String tokenElement : splittedTokens) {
+            Matcher versionMatcher = versionPattern.matcher(tokenElement);
+            if (versionMatcher.find()) {
+                model.setConfidence(90);
+                if (versionMatcher.group(1) != null) {
+                    model.setVersion(versionMatcher.group(1));
+                }
+                if (versionMatcher.group(2) != null) {
+                    model.setMajorRevision(versionMatcher.group(2));
+                }
+                if (versionMatcher.group(3) != null) {
+                    model.setMinorRevision(versionMatcher.group(3));
+                }
+                if (versionMatcher.group(4) != null) {
+                    model.setMicroRevision(versionMatcher.group(4));
+                }
+                if (versionMatcher.group(5) != null) {
+                    model.setNanoRevision(versionMatcher.group(5));
+                }
+            }
+        }
+        return model;
+    }
+}

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/BrewMozillaSubBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/BrewMozillaSubBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/IOSMozillaSubBuilder.java
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/IOSMozillaSubBuilder.java?rev=1392911&view=auto
==============================================================================
--- incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/IOSMozillaSubBuilder.java (added)
+++ incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/IOSMozillaSubBuilder.java Tue Oct  2 13:32:28 2012
@@ -0,0 +1,70 @@
+/**
+ * Copyright 2011 OpenDDR LLC
+ * This software is distributed under the terms of the GNU Lesser General Public License.
+ *
+ *
+ * This file is part of OpenDDR Simple APIs.
+ * OpenDDR Simple APIs is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OpenDDR Simple APIs is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Simple APIs.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.openddr.simpleapi.oddr.builder.os.mozilla;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.openddr.simpleapi.oddr.builder.Builder;
+import org.openddr.simpleapi.oddr.model.UserAgent;
+import org.openddr.simpleapi.oddr.model.os.OperatingSystem;
+
+public class IOSMozillaSubBuilder implements Builder {
+
+    private static final String VERSION_REGEXP = ".*(?:iPhone)?.?OS.?((\\d+)_(\\d+)(?:_(\\d+))?).*";
+    private Pattern versionPattern = Pattern.compile(VERSION_REGEXP);
+
+    public boolean canBuild(UserAgent userAgent) {
+        if (userAgent.containsIOSDevices()) {
+            return true;
+        }
+        return false;
+    }
+
+    public OperatingSystem build(UserAgent userAgent, int confidenceTreshold) {
+        OperatingSystem model = new OperatingSystem();
+        model.setMajorRevision("1");
+        model.setVendor("Apple");
+        model.setModel("iOS");
+        model.setConfidence(40);
+
+        String[] splittedTokens = userAgent.getPatternElementsInside().split(";");
+        for (String tokenElement : splittedTokens) {
+            Matcher versionMatcher = versionPattern.matcher(tokenElement);
+            if (versionMatcher.find()) {
+                model.setConfidence(90);
+
+                if (versionMatcher.group(1) != null) {
+                    model.setVersion(versionMatcher.group(1));
+                }
+                if (versionMatcher.group(2) != null) {
+                    model.setMajorRevision(versionMatcher.group(2));
+                }
+                if (versionMatcher.group(3) != null) {
+                    model.setMinorRevision(versionMatcher.group(3));
+                }
+                if (versionMatcher.group(4) != null) {
+                    model.setMicroRevision(versionMatcher.group(4));
+                }
+            }
+        }
+        return model;
+    }
+}

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/IOSMozillaSubBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/IOSMozillaSubBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/LinuxMozillaSubBuilder.java
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/LinuxMozillaSubBuilder.java?rev=1392911&view=auto
==============================================================================
--- incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/LinuxMozillaSubBuilder.java (added)
+++ incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/LinuxMozillaSubBuilder.java Tue Oct  2 13:32:28 2012
@@ -0,0 +1,62 @@
+/**
+ * Copyright 2011 OpenDDR LLC
+ * This software is distributed under the terms of the GNU Lesser General Public License.
+ *
+ *
+ * This file is part of OpenDDR Simple APIs.
+ * OpenDDR Simple APIs is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OpenDDR Simple APIs is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Simple APIs.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.openddr.simpleapi.oddr.builder.os.mozilla;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.openddr.simpleapi.oddr.builder.Builder;
+import org.openddr.simpleapi.oddr.model.BuiltObject;
+import org.openddr.simpleapi.oddr.model.UserAgent;
+import org.openddr.simpleapi.oddr.model.os.OperatingSystem;
+
+public class LinuxMozillaSubBuilder implements Builder {
+
+    private static final String DESCRIPTION_REGEXP = ".*(X11;)?.*?Linux[^;]?([^;]*)?;.*";
+    private Pattern descriptionPattern = Pattern.compile(DESCRIPTION_REGEXP);
+
+    public boolean canBuild(UserAgent userAgent) {
+        return userAgent.getCompleteUserAgent().contains("Linux") && !userAgent.getCompleteUserAgent().contains("Android");
+    }
+
+    public BuiltObject build(UserAgent userAgent, int confidenceTreshold) {
+        OperatingSystem model = new OperatingSystem();
+        model.setMajorRevision("-");
+        model.setVendor("-");
+        model.setModel("Linux");
+
+        int confidence = 60;
+
+        Matcher descriptionMatcher = descriptionPattern.matcher(userAgent.getPatternElementsInside());
+        if (descriptionMatcher.find()) {
+            if (descriptionMatcher.group(1) != null) {
+                confidence += 10;
+            }
+            if (descriptionMatcher.group(2) != null) {
+                model.setDescription(descriptionMatcher.group(2));
+                confidence += 10;
+            }
+        }
+
+        model.setConfidence(confidence);
+
+        return model;
+    }
+}

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/LinuxMozillaSubBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/LinuxMozillaSubBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/MacOSXMozillaSubBuilder.java
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/MacOSXMozillaSubBuilder.java?rev=1392911&view=auto
==============================================================================
--- incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/MacOSXMozillaSubBuilder.java (added)
+++ incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/MacOSXMozillaSubBuilder.java Tue Oct  2 13:32:28 2012
@@ -0,0 +1,69 @@
+/**
+ * Copyright 2011 OpenDDR LLC
+ * This software is distributed under the terms of the GNU Lesser General Public License.
+ *
+ *
+ * This file is part of OpenDDR Simple APIs.
+ * OpenDDR Simple APIs is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OpenDDR Simple APIs is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Simple APIs.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.openddr.simpleapi.oddr.builder.os.mozilla;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.openddr.simpleapi.oddr.builder.Builder;
+import org.openddr.simpleapi.oddr.model.BuiltObject;
+import org.openddr.simpleapi.oddr.model.UserAgent;
+import org.openddr.simpleapi.oddr.model.os.OperatingSystem;
+
+public class MacOSXMozillaSubBuilder implements Builder {
+
+    private static final String VERSION_REGEXP = ".*(?:(?:Intel)|(?:PPC)).?Mac OS X.?((\\d+)[_\\.](\\d+)(?:[_\\.](\\d+))?).*";
+    private Pattern versionPattern = Pattern.compile(VERSION_REGEXP);
+
+    public boolean canBuild(UserAgent userAgent) {
+        return userAgent.getCompleteUserAgent().contains("Macintosh");
+    }
+
+    public BuiltObject build(UserAgent userAgent, int confidenceTreshold) {
+        OperatingSystem model = new OperatingSystem();
+        model.setMajorRevision("-");
+        model.setVendor("Apple");
+        model.setModel("Mac OS X");
+
+        int confidence = 60;
+
+        Matcher versionMatcher = versionPattern.matcher(userAgent.getPatternElementsInside());
+        if (versionMatcher.find()) {
+            model.setConfidence(80);
+
+            if (versionMatcher.group(1) != null) {
+                model.setVersion(versionMatcher.group(1));
+            }
+            if (versionMatcher.group(2) != null) {
+                model.setMajorRevision(versionMatcher.group(2));
+            }
+            if (versionMatcher.group(3) != null) {
+                model.setMinorRevision(versionMatcher.group(3));
+            }
+            if (versionMatcher.group(4) != null) {
+                model.setMicroRevision(versionMatcher.group(4));
+            }
+        }
+
+        model.setConfidence(confidence);
+
+        return model;
+    }
+}

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/MacOSXMozillaSubBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/MacOSXMozillaSubBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/SymbianMozillaSubBuilder.java
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/SymbianMozillaSubBuilder.java?rev=1392911&view=auto
==============================================================================
--- incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/SymbianMozillaSubBuilder.java (added)
+++ incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/SymbianMozillaSubBuilder.java Tue Oct  2 13:32:28 2012
@@ -0,0 +1,90 @@
+/**
+ * Copyright 2011 OpenDDR LLC
+ * This software is distributed under the terms of the GNU Lesser General Public License.
+ *
+ *
+ * This file is part of OpenDDR Simple APIs.
+ * OpenDDR Simple APIs is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OpenDDR Simple APIs is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Simple APIs.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.openddr.simpleapi.oddr.builder.os.mozilla;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.openddr.simpleapi.oddr.builder.Builder;
+import org.openddr.simpleapi.oddr.model.UserAgent;
+import org.openddr.simpleapi.oddr.model.os.OperatingSystem;
+
+public class SymbianMozillaSubBuilder implements Builder {
+
+    private static final String VERSION_REGEXP = ".*Series.?60/(\\d+)(?:[\\.\\- ](\\d+))?(?:[\\.\\- ](\\d+))?.*";
+    private static final String VERSION_EXTRA = ".*Symbian(?:OS)?/(.*)";
+    private Pattern versionPattern = Pattern.compile(VERSION_REGEXP);
+    private Pattern versionExtraPattern = Pattern.compile(VERSION_EXTRA);
+
+    public boolean canBuild(UserAgent userAgent) {
+        if (userAgent.containsSymbian()) {
+            return true;
+        }
+        return false;
+    }
+
+    public OperatingSystem build(UserAgent userAgent, int confidenceTreshold) {
+        OperatingSystem model = new OperatingSystem();
+        model.setMajorRevision("1");
+        model.setVendor("Nokia");
+        model.setModel("Symbian OS");
+        model.setConfidence(40);
+
+        String[] splittedTokens = userAgent.getPatternElementsInside().split(";");
+        for (String tokenElement : splittedTokens) {
+            Matcher versionMatcher = versionPattern.matcher(tokenElement);
+            if (versionMatcher.find()) {
+                model.setDescription("Series60");
+                if (model.getConfidence() > 40) {
+                    model.setConfidence(100);
+
+                } else {
+                    model.setConfidence(90);
+                }
+
+                if (versionMatcher.group(1) != null) {
+                    model.setMajorRevision(versionMatcher.group(1));
+                }
+                if (versionMatcher.group(2) != null) {
+                    model.setMinorRevision(versionMatcher.group(2));
+                }
+                if (versionMatcher.group(3) != null) {
+                    model.setMicroRevision(versionMatcher.group(3));
+                }
+            }
+
+            Matcher versionExtraMatcher = versionExtraPattern.matcher(tokenElement);
+            if (versionExtraMatcher.find()) {
+                if (model.getConfidence() > 40) {
+                    model.setConfidence(100);
+
+                } else {
+                    model.setConfidence(85);
+                }
+
+                if (versionExtraMatcher.group(1) != null) {
+                    model.setVersion(versionExtraMatcher.group(1).trim());
+                }
+            }
+            //TODO: inference VERSION_EXTRA/VERSION_REGEXP and vice-versa
+        }
+        return model;
+    }
+}

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/SymbianMozillaSubBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/SymbianMozillaSubBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/WebOSMozillaSubBuilder.java
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/WebOSMozillaSubBuilder.java?rev=1392911&view=auto
==============================================================================
--- incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/WebOSMozillaSubBuilder.java (added)
+++ incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/WebOSMozillaSubBuilder.java Tue Oct  2 13:32:28 2012
@@ -0,0 +1,72 @@
+/**
+ * Copyright 2011 OpenDDR LLC
+ * This software is distributed under the terms of the GNU Lesser General Public License.
+ *
+ *
+ * This file is part of OpenDDR Simple APIs.
+ * OpenDDR Simple APIs is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OpenDDR Simple APIs is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Simple APIs.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.openddr.simpleapi.oddr.builder.os.mozilla;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.openddr.simpleapi.oddr.builder.Builder;
+import org.openddr.simpleapi.oddr.model.UserAgent;
+import org.openddr.simpleapi.oddr.model.os.OperatingSystem;
+
+public class WebOSMozillaSubBuilder implements Builder {
+
+    private static final String VERSION_REGEXP = ".*?webOS.?((\\d+)\\.(\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?(.*))";
+    private Pattern versionPattern = Pattern.compile(VERSION_REGEXP);
+
+    public boolean canBuild(UserAgent userAgent) {
+        if (userAgent.getPatternElementsInside().contains("webOS")) {
+            return true;
+        }
+        return false;
+    }
+
+    public OperatingSystem build(UserAgent userAgent, int confidenceTreshold) {
+        OperatingSystem model = new OperatingSystem();
+        model.setMajorRevision("1");
+        model.setVendor("Palm");
+        model.setModel("Web OS");
+        model.setConfidence(40);
+
+        String[] splittedTokens = userAgent.getPatternElementsInside().split(";");
+        for (String tokenElement : splittedTokens) {
+            Matcher versionMatcher = versionPattern.matcher(tokenElement);
+            if (versionMatcher.find()) {
+                model.setConfidence(90);
+                if (versionMatcher.group(1) != null) {
+                    model.setVersion(versionMatcher.group(1));
+                }
+                if (versionMatcher.group(2) != null) {
+                    model.setMajorRevision(versionMatcher.group(2));
+                }
+                if (versionMatcher.group(3) != null) {
+                    model.setMinorRevision(versionMatcher.group(3));
+                }
+                if (versionMatcher.group(4) != null) {
+                    model.setMicroRevision(versionMatcher.group(4));
+                }
+                if (versionMatcher.group(5) != null) {
+                    model.setNanoRevision(versionMatcher.group(5));
+                }
+            }
+        }
+        return model;
+    }
+}

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/WebOSMozillaSubBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/WebOSMozillaSubBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/WinCEMozillaSubBuilder.java
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/WinCEMozillaSubBuilder.java?rev=1392911&view=auto
==============================================================================
--- incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/WinCEMozillaSubBuilder.java (added)
+++ incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/WinCEMozillaSubBuilder.java Tue Oct  2 13:32:28 2012
@@ -0,0 +1,133 @@
+/**
+ * Copyright 2011 OpenDDR LLC
+ * This software is distributed under the terms of the GNU Lesser General Public License.
+ *
+ *
+ * This file is part of OpenDDR Simple APIs.
+ * OpenDDR Simple APIs is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OpenDDR Simple APIs is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Simple APIs.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.openddr.simpleapi.oddr.builder.os.mozilla;
+
+import java.util.Scanner;
+import java.util.regex.MatchResult;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.openddr.simpleapi.oddr.builder.Builder;
+import org.openddr.simpleapi.oddr.model.UserAgent;
+import org.openddr.simpleapi.oddr.model.os.OperatingSystem;
+
+public class WinCEMozillaSubBuilder implements Builder {
+
+    private static final String VERSION_REGEXP = ".*Windows.?CE.?((\\d+)?\\.?(\\d+)?\\.?(\\d+)?).*";
+    private static final String VERSION_MSIE_IEMOBILE = "(?:.*(?:MSIE).?(\\d+)\\.(\\d+).*)|(?:.*IEMobile.?(\\d+)\\.(\\d+).*)";
+    private Pattern versionPattern = Pattern.compile(VERSION_REGEXP);
+    private Pattern versionMsiePattern = Pattern.compile(VERSION_MSIE_IEMOBILE);
+
+    public boolean canBuild(UserAgent userAgent) {
+        if (userAgent.containsWindowsPhone()) {
+            if (userAgent.getPatternElementsInside().matches(".*Windows.?CE.*")) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public OperatingSystem build(UserAgent userAgent, int confidenceTreshold) {
+        OperatingSystem model = new OperatingSystem();
+        model.setMajorRevision("1");
+        model.setVendor("Microsoft");
+        model.setModel("Windows Phone");
+        model.setConfidence(40);
+
+        String[] splittedTokens = userAgent.getPatternElementsInside().split(";");
+        for (String tokenElement : splittedTokens) {
+            Matcher versionMatcher = versionPattern.matcher(tokenElement);
+            if (versionMatcher.find()) {
+                if (model.getConfidence() > 40) {
+                    model.setConfidence(95);
+
+                } else {
+                    model.setConfidence(85);
+                }
+
+                if (versionMatcher.group(1) != null) {
+                    model.setDescription(versionMatcher.group(1));
+                }
+                if (versionMatcher.group(2) != null) {
+                    model.setMajorRevision(versionMatcher.group(2));
+                }
+                if (versionMatcher.group(3) != null) {
+                    model.setMinorRevision(versionMatcher.group(3));
+                }
+                if (versionMatcher.group(4) != null) {
+                    model.setMicroRevision(versionMatcher.group(4));
+                }
+            }
+
+            Matcher versionMsieMatcher = versionMsiePattern.matcher(tokenElement);
+            if (versionMsieMatcher.find()) {
+                String str = model.getVersion();
+                if (str == null || str.length() < 7) {
+                    str = "0.0.0.0";
+                }
+                String[] subV = str.split("\\.");
+                int count = 0;
+                for (int idx = 1; idx <= versionMsieMatcher.groupCount(); idx++) {
+                    if ((idx >= 1) && (idx <= 4) && versionMsieMatcher.group(idx) != null) {
+                        subV[idx - 1] = versionMsieMatcher.group(idx);
+                        count++;
+                    }
+                }
+                model.setVersion(subV[0] + "." + subV[1] + "." + subV[2] + "." + subV[3]);
+
+                if (model.getConfidence() > 40) {
+                    model.setConfidence(95);
+
+                } else {
+                    model.setConfidence(count * 18);
+                }
+            }
+        }
+        setWinCeVersion(model);
+        return model;
+    }
+
+    private void setWinCeVersion(OperatingSystem model) {
+        //TODO: to be refined
+        String osV = model.getVersion();
+        if (osV == null) {
+            return;
+
+        } else if (!model.getMajorRevision().equals("1")) {
+            return;
+        }
+
+        if (osV.matches(".*(\\d+).(\\d+).(\\d+).(\\d+).*")) {
+            Scanner s = new Scanner(osV);
+            s.findInLine(".*(\\d+).(\\d+).(\\d+).(\\d+).*");
+            MatchResult result = s.match();
+            if (result.group(1).equals("4")) {
+                model.setMajorRevision("5");
+
+            } else if (result.group(1).equals("6")) {
+                model.setMajorRevision("6");
+
+                if (result.group(3).equals("7")) {
+                    model.setMinorRevision("1");
+                }
+            }
+        }
+    }
+}

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/WinCEMozillaSubBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/WinCEMozillaSubBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/WinPhoneMozillaSubBuilder.java
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/WinPhoneMozillaSubBuilder.java?rev=1392911&view=auto
==============================================================================
--- incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/WinPhoneMozillaSubBuilder.java (added)
+++ incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/WinPhoneMozillaSubBuilder.java Tue Oct  2 13:32:28 2012
@@ -0,0 +1,96 @@
+/**
+ * Copyright 2011 OpenDDR LLC
+ * This software is distributed under the terms of the GNU Lesser General Public License.
+ *
+ *
+ * This file is part of OpenDDR Simple APIs.
+ * OpenDDR Simple APIs is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OpenDDR Simple APIs is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Simple APIs.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.openddr.simpleapi.oddr.builder.os.mozilla;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.openddr.simpleapi.oddr.builder.Builder;
+import org.openddr.simpleapi.oddr.model.UserAgent;
+import org.openddr.simpleapi.oddr.model.os.OperatingSystem;
+
+public class WinPhoneMozillaSubBuilder implements Builder {
+
+    private static final String VERSION_REGEXP = ".*Windows.?Phone.?(?:OS)?.?((\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?(?:\\.(\\d+))?).*";
+    private Pattern versionPattern = Pattern.compile(VERSION_REGEXP);
+
+    public boolean canBuild(UserAgent userAgent) {
+        if (userAgent.containsWindowsPhone()) {
+            if ((userAgent.getPatternElementsInside() + userAgent.getPatternElementsPost()).matches(".*Windows.?Phone.*")) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public OperatingSystem build(UserAgent userAgent, int confidenceTreshold) {
+        OperatingSystem model = new OperatingSystem();
+        model.setVendor("Microsoft");
+        model.setModel("Windows Phone");
+        model.setConfidence(40);
+        boolean isInPostMoz = false;
+
+        String toSplit = userAgent.getPatternElementsInside();
+        if (!toSplit.matches(VERSION_REGEXP)) {
+            toSplit = userAgent.getPatternElementsPost();
+            isInPostMoz = true;
+        }
+
+        String[] splittedTokens = toSplit.split(";");
+        for (String tokenElement : splittedTokens) {
+            Matcher versionMatcher = versionPattern.matcher(tokenElement);
+            if (versionMatcher.find()) {
+                if (isInPostMoz) {
+                    model.setConfidence(85);
+
+                } else {
+                    model.setConfidence(90);
+                }
+
+                if (versionMatcher.group(1) != null) {
+                    model.setVersion(versionMatcher.group(1));
+                }
+
+                if (versionMatcher.group(2) != null) {
+                    model.setMajorRevision(versionMatcher.group(2));
+                }
+
+                if (versionMatcher.group(3) != null) {
+                    model.setMinorRevision(versionMatcher.group(3));
+                }
+
+                if (versionMatcher.group(4) != null) {
+                    model.setMicroRevision(versionMatcher.group(4));
+                }
+
+                if (versionMatcher.group(5) != null) {
+                    model.setNanoRevision(versionMatcher.group(5));
+                }
+            }
+
+            if (model.getMajorRevision().equals("0") && model.getMinorRevision().equals("0")) {
+                model.setMajorRevision("6");
+                model.setMinorRevision("5");
+            }
+            model.setDescription("Windows Phone " + model.getMajorRevision() + "." + model.getMinorRevision() + "." + model.getMicroRevision() + "." + model.getNanoRevision());
+        }
+        return model;
+    }
+}

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/WinPhoneMozillaSubBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/builder/os/mozilla/WinPhoneMozillaSubBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/cache/Cache.java
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/cache/Cache.java?rev=1392911&view=auto
==============================================================================
--- incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/cache/Cache.java (added)
+++ incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/cache/Cache.java Tue Oct  2 13:32:28 2012
@@ -0,0 +1,37 @@
+/**
+ * Copyright 2011 OpenDDR LLC
+ * This software is distributed under the terms of the GNU Lesser General Public License.
+ *
+ *
+ * This file is part of OpenDDR Simple APIs.
+ * OpenDDR Simple APIs is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OpenDDR Simple APIs is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Simple APIs.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.openddr.simpleapi.oddr.cache;
+
+import java.util.Collection;
+import java.util.Map;
+
+public interface Cache {
+
+    public Object getCachedElement(String id);
+
+    public void setCachedElement(String id, Object object);
+
+    public void clear();
+
+    public int usedEntries();
+
+    public Collection<Map.Entry> getAll();
+}

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/cache/Cache.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/cache/Cache.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/cache/CacheImpl.java
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/cache/CacheImpl.java?rev=1392911&view=auto
==============================================================================
--- incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/cache/CacheImpl.java (added)
+++ incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/cache/CacheImpl.java Tue Oct  2 13:32:28 2012
@@ -0,0 +1,66 @@
+/**
+ * Copyright 2011 OpenDDR LLC
+ * This software is distributed under the terms of the GNU Lesser General Public License.
+ *
+ *
+ * This file is part of OpenDDR Simple APIs.
+ * OpenDDR Simple APIs is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OpenDDR Simple APIs is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Simple APIs.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.openddr.simpleapi.oddr.cache;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+public class CacheImpl implements Cache {
+
+    private static final float hashTableLoadFactor = 0.75f;
+    private LinkedHashMap map;
+    private int cacheSize;
+
+    public CacheImpl() {
+        this.cacheSize = 100;
+        int hashTableCapacity = (int) Math.ceil(cacheSize / hashTableLoadFactor) + 1;
+        map = new LinkedHashMap(hashTableCapacity, hashTableLoadFactor, true) {
+            private static final long serialVersionUID = 1;
+
+            @Override
+            protected boolean removeEldestEntry(Map.Entry eldest) {
+                return size() > CacheImpl.this.cacheSize;
+            }
+        };
+    }
+
+    public synchronized Object getCachedElement(String id) {
+        return map.get(id);
+    }
+
+    public synchronized void setCachedElement(String id, Object object) {
+        map.put(id, object);
+    }
+
+    public synchronized void clear() {
+        map.clear();
+    }
+
+    public synchronized int usedEntries() {
+        return map.size();
+    }
+
+    public synchronized Collection<Map.Entry> getAll() {
+        return new ArrayList<Map.Entry>(map.entrySet());
+    }
+}

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/cache/CacheImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/cache/CacheImpl.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/documenthandler/BrowserDatasourceHandler.java
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/documenthandler/BrowserDatasourceHandler.java?rev=1392911&view=auto
==============================================================================
--- incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/documenthandler/BrowserDatasourceHandler.java (added)
+++ incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/documenthandler/BrowserDatasourceHandler.java Tue Oct  2 13:32:28 2012
@@ -0,0 +1,139 @@
+/**
+ * Copyright 2011 OpenDDR LLC
+ * This software is distributed under the terms of the GNU Lesser General Public License.
+ *
+ *
+ * This file is part of OpenDDR Simple APIs.
+ * OpenDDR Simple APIs is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OpenDDR Simple APIs is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Simple APIs.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.openddr.simpleapi.oddr.documenthandler;
+
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TreeMap;
+import org.openddr.simpleapi.oddr.ODDRService;
+import org.openddr.simpleapi.oddr.ODDRVocabularyService;
+import org.openddr.simpleapi.oddr.model.browser.Browser;
+import org.openddr.simpleapi.oddr.vocabulary.VocabularyHolder;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+public class BrowserDatasourceHandler extends DefaultHandler {
+
+    private static final String ELEMENT_BROWSER_DESCRIPTION = "browser";
+    private static final String ELEMENT_PROPERTY = "property";
+    private static final String ATTRIBUTE_BROWSER_ID = "id";
+    private static final String ATTRIBUTE_PROPERTY_NAME = "name";
+    private static final String ATTRIBUTE_PROPERTY_VALUE = "value";
+    private String propertyName = null;
+    private String propertyValue = null;
+    private Browser browser = null;
+    private String browserId = null;
+    private Map properties = null;
+    private Map<String, Browser> browsers = null;
+    private VocabularyHolder vocabularyHolder = null;
+
+    public BrowserDatasourceHandler() {
+        this.browsers = new TreeMap<String, Browser>(new Comparator<String>() {
+
+            public int compare(String keya, String keyb) {
+                return keya.compareTo(keyb);
+            }
+        });
+    }
+
+    public BrowserDatasourceHandler(VocabularyHolder vocabularyHolder) {
+        this.browsers = new TreeMap<String, Browser>(new Comparator<String>() {
+
+            public int compare(String keya, String keyb) {
+                return keya.compareTo(keyb);
+            }
+        });
+        try {
+            vocabularyHolder.existVocabulary(ODDRVocabularyService.ODDR_LIMITED_VOCABULARY_IRI);
+            this.vocabularyHolder = vocabularyHolder;
+
+        } catch (Exception ex) {
+            vocabularyHolder = null;
+        }
+    }
+
+    @Override
+    public void startDocument() throws SAXException {
+        super.startDocument();
+    }
+
+    @Override
+    public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException {
+        if (ELEMENT_BROWSER_DESCRIPTION.equals(name)) {
+            startBrowserDescription(attributes);
+
+        } else if (ELEMENT_PROPERTY.equals(name)) {
+            startProperty(attributes);
+        }
+    }
+
+    @Override
+    public void endElement(String uri, String localName, String name) throws SAXException {
+        if (ELEMENT_BROWSER_DESCRIPTION.equals(name)) {
+            endBrowserDescription();
+
+        } else if (ELEMENT_PROPERTY.equals(name)) {
+            endProperty();
+        }
+    }
+
+    private void startBrowserDescription(Attributes attributes) {
+        properties = new HashMap();
+        browserId = attributes.getValue(ATTRIBUTE_BROWSER_ID);
+        browser = new Browser(properties);
+    }
+
+    private void startProperty(Attributes attributes) {
+        propertyName = attributes.getValue(ATTRIBUTE_PROPERTY_NAME);
+        propertyValue = attributes.getValue(ATTRIBUTE_PROPERTY_VALUE);
+
+        if (vocabularyHolder != null) {
+            try {
+                vocabularyHolder.existProperty(propertyName, ODDRService.ASPECT_WEB_BROWSER, ODDRVocabularyService.ODDR_LIMITED_VOCABULARY_IRI);
+                properties.put(propertyName.intern(), propertyValue);
+
+            } catch (Exception ex) {
+                //property non loaded
+            }
+
+        } else {
+            properties.put(propertyName.intern(), propertyValue);
+        }
+    }
+
+    private void endProperty() {
+    }
+
+    private void endBrowserDescription() {
+        browsers.put(browserId, browser);
+        properties = null;
+    }
+
+    @Override
+    public void endDocument() throws SAXException {
+    }
+
+    public Map<String, Browser> getBrowsers() {
+        return browsers;
+    }
+}

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/documenthandler/BrowserDatasourceHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/documenthandler/BrowserDatasourceHandler.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/documenthandler/DeviceBuilderHandler.java
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/documenthandler/DeviceBuilderHandler.java?rev=1392911&view=auto
==============================================================================
--- incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/documenthandler/DeviceBuilderHandler.java (added)
+++ incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/documenthandler/DeviceBuilderHandler.java Tue Oct  2 13:32:28 2012
@@ -0,0 +1,179 @@
+/**
+ * Copyright 2011 OpenDDR LLC
+ * This software is distributed under the terms of the GNU Lesser General Public License.
+ *
+ *
+ * This file is part of OpenDDR Simple APIs.
+ * OpenDDR Simple APIs is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OpenDDR Simple APIs is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Simple APIs.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.openddr.simpleapi.oddr.documenthandler;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.openddr.simpleapi.oddr.builder.device.DeviceBuilder;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+public class DeviceBuilderHandler extends DefaultHandler {
+
+    private Object BUILDER_DEVICE = "builder";
+    private static final String ELEMENT_DEVICE = "device";
+    private static final String ELEMENT_PROPERTY = "property";
+    private static final String ELEMENT_LIST = "list";
+    private static final String ELEMENT_VALUE = "value";
+    private static final String ATTRIBUTE_DEVICE_ID = "id";
+    private String character = "";
+    private DeviceBuilder deviceBuilderInstance;
+    private String deviceId = null;
+    private List builderProperties = null;
+    private boolean inList = false;
+    private boolean inValue = false;
+    private List<DeviceBuilder> builders;
+
+    public DeviceBuilderHandler() {
+        this.builders = new ArrayList<DeviceBuilder>();
+    }
+
+    public DeviceBuilderHandler(List builders) {
+        this.builders = builders;
+    }
+
+    @Override
+    public void startDocument() throws SAXException {
+        super.startDocument();
+    }
+
+    @Override
+    public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException {
+        if (BUILDER_DEVICE.equals(name)) {
+            startBuilderElement(attributes);
+
+        } else if (ELEMENT_DEVICE.equals(name)) {
+            startDeviceElement(attributes);
+
+        } else if (ELEMENT_PROPERTY.equals(name)) {
+            startPropertyElement(attributes);
+
+        } else if (ELEMENT_LIST.equals(name)) {
+            startListElement(attributes);
+
+        } else if (ELEMENT_VALUE.equals(name)) {
+            startValueElement(attributes);
+        }
+    }
+
+    @Override
+    public void characters(char[] ch, int start, int length) throws SAXException {
+        if (inList && inValue) {
+            String s = new String(ch, start, length);
+            character = character + s;
+        }
+    }
+
+    @Override
+    public void endElement(String uri, String localName, String name) throws SAXException {
+        if (BUILDER_DEVICE.equals(name)) {
+            endBuilderElement();
+
+        } else if (ELEMENT_DEVICE.equals(name)) {
+            endDeviceElement();
+
+        } else if (ELEMENT_PROPERTY.equals(name)) {
+            endPropertyElement();
+
+        } else if (ELEMENT_LIST.equals(name)) {
+            endListElement();
+
+        } else if (ELEMENT_VALUE.equals(name)) {
+            endValueElement();
+        }
+    }
+
+    @Override
+    public void endDocument() throws SAXException {
+    }
+
+    private void startBuilderElement(Attributes attributes) {
+        String builderClassName = attributes.getValue("class");
+        try {
+            Class deviceBuilderClass = Class.forName(builderClassName);
+            deviceBuilderInstance = null;
+            for (DeviceBuilder deviceBuilder : builders) {
+                if (deviceBuilder.getClass().getName().equals(deviceBuilderClass.getName())) {
+                    deviceBuilderInstance = deviceBuilder;
+                    break;
+                }
+            }
+            if (deviceBuilderInstance == null) {
+                deviceBuilderInstance = (DeviceBuilder) deviceBuilderClass.newInstance();
+                builders.add(deviceBuilderInstance);
+            }
+
+        } catch (InstantiationException ex) {
+            throw new IllegalArgumentException("Can not instantiate class: " + builderClassName + " described in device builder document");
+
+        } catch (IllegalAccessException ex) {
+            throw new IllegalArgumentException("Can not instantiate class: " + builderClassName + " described in device builder document due to constructor access restriction");
+
+        } catch (ClassNotFoundException ex) {
+            throw new IllegalArgumentException("Can not find class: " + builderClassName + " described in device builder document");
+
+        }
+    }
+
+    private void startDeviceElement(Attributes attributes) {
+        deviceId = attributes.getValue(ATTRIBUTE_DEVICE_ID);
+        builderProperties = new ArrayList();
+    }
+
+    private void startPropertyElement(Attributes attributes) {
+    }
+
+    private void startListElement(Attributes attributes) {
+        inList = true;
+    }
+
+    private void startValueElement(Attributes attributes) {
+        inValue = true;
+    }
+
+    private void endBuilderElement() {
+        deviceBuilderInstance = null;
+    }
+
+    private void endDeviceElement() {
+        deviceBuilderInstance.putDevice(deviceId, builderProperties);
+        deviceId = null;
+        builderProperties = null;
+    }
+
+    private void endPropertyElement() {
+    }
+
+    private void endListElement() {
+        inList = false;
+    }
+
+    private void endValueElement() {
+        builderProperties.add(character);
+        character = "";
+        inValue = false;
+    }
+
+    public DeviceBuilder[] getBuilders() {
+        return builders.toArray(new DeviceBuilder[builders.size()]);
+    }
+}

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/documenthandler/DeviceBuilderHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/documenthandler/DeviceBuilderHandler.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/documenthandler/DeviceDatasourceHandler.java
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/documenthandler/DeviceDatasourceHandler.java?rev=1392911&view=auto
==============================================================================
--- incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/documenthandler/DeviceDatasourceHandler.java (added)
+++ incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/documenthandler/DeviceDatasourceHandler.java Tue Oct  2 13:32:28 2012
@@ -0,0 +1,156 @@
+/**
+ * Copyright 2011 OpenDDR LLC
+ * This software is distributed under the terms of the GNU Lesser General Public License.
+ *
+ *
+ * This file is part of OpenDDR Simple APIs.
+ * OpenDDR Simple APIs is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OpenDDR Simple APIs is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Simple APIs.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.openddr.simpleapi.oddr.documenthandler;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.openddr.simpleapi.oddr.ODDRService;
+import org.openddr.simpleapi.oddr.ODDRVocabularyService;
+import org.openddr.simpleapi.oddr.model.device.Device;
+import org.openddr.simpleapi.oddr.vocabulary.VocabularyHolder;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+public class DeviceDatasourceHandler extends DefaultHandler {
+
+    private static final String PROPERTY_ID = "id";
+    private static final String ELEMENT_DEVICE = "device";
+    private static final String ELEMENT_PROPERTY = "property";
+    private static final String ATTRIBUTE_DEVICE_ID = "id";
+    private static final String ATTRIBUTE_DEVICE_PARENT_ID = "parentId";
+    private static final String ATTRIBUTE_PROPERTY_NAME = "name";
+    private static final String ATTRIBUTE_PROPERTY_VALUE = "value";
+    private String propertyName = null;
+    private String propertyValue = null;
+    private Device device = null;
+    private Map properties = null;
+    private Map<String, Device> devices = null;
+    private boolean patching = false;
+    private VocabularyHolder vocabularyHolder = null;
+
+    public DeviceDatasourceHandler() {
+        this.devices = new HashMap<String, Device>();
+    }
+
+    public DeviceDatasourceHandler(Map devices) {
+        this.devices = devices;
+    }
+
+    public DeviceDatasourceHandler(Map devices, VocabularyHolder vocabularyHolder) {
+        this.devices = devices;
+        try {
+            vocabularyHolder.existVocabulary(ODDRVocabularyService.ODDR_LIMITED_VOCABULARY_IRI);
+            this.vocabularyHolder = vocabularyHolder;
+
+        } catch (Exception ex) {
+            vocabularyHolder = null;
+        }
+    }
+
+    @Override
+    public void startDocument() throws SAXException {
+        super.startDocument();
+    }
+
+    @Override
+    public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException {
+        if (ELEMENT_DEVICE.equals(name)) {
+            startDeviceElement(attributes);
+
+        } else if (ELEMENT_PROPERTY.equals(name)) {
+            startPropertyElement(attributes);
+        }
+    }
+
+    @Override
+    public void characters(char[] ch, int start, int length) throws SAXException {
+    }
+
+    @Override
+    public void endElement(String uri, String localName, String name) throws SAXException {
+        if (ELEMENT_DEVICE.equals(name)) {
+            endDeviceElement();
+
+        } else if (ELEMENT_PROPERTY.equals(name)) {
+            endPropertyElement();
+        }
+    }
+
+    @Override
+    public void endDocument() throws SAXException {
+    }
+
+    private void startDeviceElement(Attributes attributes) {
+        device = new Device();
+        device.setId(attributes.getValue(ATTRIBUTE_DEVICE_ID));
+        if (attributes.getValue(ATTRIBUTE_DEVICE_PARENT_ID) != null) {
+            device.setParentId(attributes.getValue(ATTRIBUTE_DEVICE_PARENT_ID));
+        }
+        properties = new HashMap();
+    }
+
+    private void startPropertyElement(Attributes attributes) {
+        propertyName = attributes.getValue(ATTRIBUTE_PROPERTY_NAME);
+        propertyValue = attributes.getValue(ATTRIBUTE_PROPERTY_VALUE);
+
+        if (vocabularyHolder != null) {
+            try {
+                vocabularyHolder.existProperty(propertyName, ODDRService.ASPECT_DEVICE, ODDRVocabularyService.ODDR_LIMITED_VOCABULARY_IRI);
+                properties.put(propertyName.intern(), propertyValue);
+
+            } catch (Exception ex) {
+                //property non loaded
+            }
+
+        } else {
+            properties.put(propertyName.intern(), propertyValue);
+        }
+    }
+
+    private void endDeviceElement() {
+        if (devices.containsKey(device.getId())) {
+            if (patching) {
+                devices.get(device.getId()).getPropertiesMap().putAll(properties);
+                return;
+
+            } else {
+                //TODO: WARNING already present
+            }
+        }
+        properties.put(PROPERTY_ID, device.getId());
+        device.putPropertiesMap(properties);
+        devices.put(device.getId(), device);
+        device = null;
+        properties = null;
+    }
+
+    private void endPropertyElement() {
+    }
+
+    public Map<String, Device> getDevices() {
+        return devices;
+    }
+
+    public void setPatching(boolean patching) {
+        this.patching = patching;
+    }
+}

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/documenthandler/DeviceDatasourceHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/documenthandler/DeviceDatasourceHandler.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/documenthandler/OperatingSystemDatasourceHandler.java
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/documenthandler/OperatingSystemDatasourceHandler.java?rev=1392911&view=auto
==============================================================================
--- incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/documenthandler/OperatingSystemDatasourceHandler.java (added)
+++ incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/documenthandler/OperatingSystemDatasourceHandler.java Tue Oct  2 13:32:28 2012
@@ -0,0 +1,139 @@
+/**
+ * Copyright 2011 OpenDDR LLC
+ * This software is distributed under the terms of the GNU Lesser General Public License.
+ *
+ *
+ * This file is part of OpenDDR Simple APIs.
+ * OpenDDR Simple APIs is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OpenDDR Simple APIs is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Simple APIs.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.openddr.simpleapi.oddr.documenthandler;
+
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TreeMap;
+import org.openddr.simpleapi.oddr.ODDRService;
+import org.openddr.simpleapi.oddr.ODDRVocabularyService;
+import org.openddr.simpleapi.oddr.model.os.OperatingSystem;
+import org.openddr.simpleapi.oddr.vocabulary.VocabularyHolder;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+public class OperatingSystemDatasourceHandler extends DefaultHandler {
+
+    private static final String ELEMENT_OPERATING_SYSTEM_DESCRIPTION = "operatingSystem";
+    private static final String ELEMENT_PROPERTY = "property";
+    private static final String ATTRIBUTE_BROWSER_ID = "id";
+    private static final String ATTRIBUTE_PROPERTY_NAME = "name";
+    private static final String ATTRIBUTE_PROPERTY_VALUE = "value";
+    private String propertyName = null;
+    private String propertyValue = null;
+    private OperatingSystem operatingSystem = null;
+    private String operatingSystemId = null;
+    private Map properties = null;
+    private Map<String, OperatingSystem> operatingSystems = null;
+    private VocabularyHolder vocabularyHolder = null;
+
+    public OperatingSystemDatasourceHandler() {
+        this.operatingSystems = new TreeMap<String, OperatingSystem>(new Comparator<String>() {
+
+            public int compare(String keya, String keyb) {
+                return keya.compareTo(keyb);
+            }
+        });
+    }
+
+    public OperatingSystemDatasourceHandler(VocabularyHolder vocabularyHolder) {
+        this.operatingSystems = new TreeMap<String, OperatingSystem>(new Comparator<String>() {
+
+            public int compare(String keya, String keyb) {
+                return keya.compareTo(keyb);
+            }
+        });
+        try {
+            vocabularyHolder.existVocabulary(ODDRVocabularyService.ODDR_LIMITED_VOCABULARY_IRI);
+            this.vocabularyHolder = vocabularyHolder;
+
+        } catch (Exception ex) {
+            vocabularyHolder = null;
+        }
+    }
+
+    @Override
+    public void startDocument() throws SAXException {
+        super.startDocument();
+    }
+
+    @Override
+    public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException {
+        if (ELEMENT_OPERATING_SYSTEM_DESCRIPTION.equals(name)) {
+            startOperatingSystemDescription(attributes);
+
+        } else if (ELEMENT_PROPERTY.equals(name)) {
+            startProperty(attributes);
+        }
+    }
+
+    @Override
+    public void endElement(String uri, String localName, String name) throws SAXException {
+        if (ELEMENT_OPERATING_SYSTEM_DESCRIPTION.equals(name)) {
+            endOperatingSystemDescription();
+
+        } else if (ELEMENT_PROPERTY.equals(name)) {
+            endProperty();
+        }
+    }
+
+    private void startOperatingSystemDescription(Attributes attributes) {
+        properties = new HashMap();
+        operatingSystemId = attributes.getValue(ATTRIBUTE_BROWSER_ID);
+        operatingSystem = new OperatingSystem(properties);
+    }
+
+    private void startProperty(Attributes attributes) {
+        propertyName = attributes.getValue(ATTRIBUTE_PROPERTY_NAME);
+        propertyValue = attributes.getValue(ATTRIBUTE_PROPERTY_VALUE);
+
+        if (vocabularyHolder != null) {
+            try {
+                vocabularyHolder.existProperty(propertyName, ODDRService.ASPECT_OPERATIVE_SYSTEM, ODDRVocabularyService.ODDR_LIMITED_VOCABULARY_IRI);
+                properties.put(propertyName.intern(), propertyValue);
+
+            } catch (Exception ex) {
+                //property non loaded
+            }
+
+        } else {
+            properties.put(propertyName.intern(), propertyValue);
+        }
+    }
+
+    private void endProperty() {
+    }
+
+    private void endOperatingSystemDescription() {
+        operatingSystems.put(operatingSystemId, operatingSystem);
+        properties = null;
+    }
+
+    @Override
+    public void endDocument() throws SAXException {
+    }
+
+    public Map<String, OperatingSystem> getOperatingSystems() {
+        return operatingSystems;
+    }
+}

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/documenthandler/OperatingSystemDatasourceHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/devicemap/trunk/openddr/java/src/org/openddr/simpleapi/oddr/documenthandler/OperatingSystemDatasourceHandler.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL