Index: trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java	(revision 6816)
+++ trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java	(revision 6821)
@@ -1,4 +1,6 @@
 // License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.data.osm;
+
+import org.openstreetmap.josm.tools.Utils;
 
 import static org.openstreetmap.josm.tools.I18n.tr;
@@ -701,14 +703,32 @@
     @Override
     public String getLocalName() {
-        String key = "name:" + Locale.getDefault().toString();
-        if (get(key) != null)
-            return get(key);
-        key = "name:" + Locale.getDefault().getLanguage() + "_" + Locale.getDefault().getCountry();
-        if (get(key) != null)
-            return get(key);
-        key = "name:" + Locale.getDefault().getLanguage();
-        if (get(key) != null)
-            return get(key);
+        final Locale locale = Locale.getDefault();
+        String key = "name:" + locale.toString();
+        String val = get(key);
+        if (val != null)
+            return val;
+
+        final String language = locale.getLanguage();
+        key = "name:" + language + "_" + locale.getCountry();
+        val = get(key);
+        if (val != null)
+            return val;
+
+        key = "name:" + language;
+        val = get(key);
+        if (val != null)
+            return val;
+
         return getName();
+    }
+
+    /**
+     * Tests whether this primitive contains a tag consisting of {@code key} and {@code values}.
+     * @param key the key forming the tag.
+     * @param value value forming the tag.
+     * @return true iff primitive contains a tag consisting of {@code key} and {@code value}.
+     */
+    public boolean hasTag(String key, String value) {
+        return Utils.equal(value, get(key));
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/mappaint/xml/Prototype.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/xml/Prototype.java	(revision 6816)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/xml/Prototype.java	(revision 6821)
@@ -25,9 +25,12 @@
     public String getCode() {
         if(code == null) {
-            code = "";
-            if (conditions != null) {
+            if (conditions == null || conditions.isEmpty()) {
+                code = "";
+            } else {
+                final StringBuilder sb = new StringBuilder();
                 for(XmlCondition r: conditions) {
-                    code += r.toCode();
+                    r.appendCode(sb);
                 }
+                code = sb.toString();
             }
         }
@@ -42,7 +45,11 @@
         {
             String k = primitive.get(r.key);
+
+            if (k == null || (r.value != null && !k.equals(r.value)))
+                return false;
+
             String bv = OsmUtils.getNamedOsmBoolean(r.boolValue);
-            if(k == null || (r.value != null && !k.equals(r.value))
-                    || (bv != null && !bv.equals(OsmUtils.getNamedOsmBoolean(k))))
+
+            if (bv != null && !bv.equals(OsmUtils.getNamedOsmBoolean(k)))
                 return false;
         }
Index: trunk/src/org/openstreetmap/josm/gui/mappaint/xml/XmlCondition.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/xml/XmlCondition.java	(revision 6816)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/xml/XmlCondition.java	(revision 6821)
@@ -38,7 +38,15 @@
       return "Rule["+key+","+(boolValue != null ? "b="+boolValue:"v="+value)+"]";
     }
-    public String toCode()
+
+    public void appendCode(StringBuilder sb)
     {
-      return "[k="+key+(boolValue != null ? ",b="+boolValue:",v="+value)+"]";
+        sb.append("[k=").append(key);
+
+        if (boolValue != null)
+            sb.append(",b=").append(boolValue);
+        else
+            sb.append(",v=").append(value);
+
+        sb.append("]");
     }
 }
