Ticket #8902: primitives.diff
| File primitives.diff, 4.3 KB (added by , 13 years ago) |
|---|
-
src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java
1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import org.openstreetmap.josm.tools.Utils; 5 4 6 import static org.openstreetmap.josm.tools.I18n.tr; 5 7 6 8 import java.text.MessageFormat; … … 694 696 */ 695 697 @Override 696 698 public String getLocalName() { 697 String key = "name:" + Locale.getDefault().toString(); 698 if (get(key) != null) 699 return get(key); 700 key = "name:" + Locale.getDefault().getLanguage() + "_" + Locale.getDefault().getCountry(); 701 if (get(key) != null) 702 return get(key); 703 key = "name:" + Locale.getDefault().getLanguage(); 704 if (get(key) != null) 705 return get(key); 699 final Locale locale = Locale.getDefault(); 700 String key = "name:" + locale.toString(); 701 String val = get(key); 702 if (val != null) 703 return val; 704 705 final String language = locale.getLanguage(); 706 key = "name:" + language + "_" + locale.getCountry(); 707 val = get(key); 708 if (val != null) 709 return val; 710 711 key = "name:" + language; 712 val = get(key); 713 if (val != null) 714 return val; 715 706 716 return getName(); 707 717 } 708 718 709 719 /** 720 * Tests whether this primitive contains a tag consisting of {@code key} and {@code values}. 721 * @param key the key forming the tag. 722 * @param value value forming the tag. 723 * @return true iff primitive contains a tag consisting of {@code key} and {@code value}. 724 */ 725 public boolean hasTag(String key, String value) { 726 return Utils.equal(value, get(key)); 727 } 728 729 /** 710 730 * Tests whether this primitive contains a tag consisting of {@code key} and any of {@code values}. 711 731 * @param key the key forming the tag. 712 732 * @param values one or many values forming the tag. -
src/org/openstreetmap/josm/gui/mappaint/xml/Prototype.java
24 24 25 25 public String getCode() { 26 26 if(code == null) { 27 code = ""; 28 if (conditions != null) { 27 if (conditions == null || conditions.isEmpty()) { 28 code = ""; 29 } else { 30 final StringBuilder sb = new StringBuilder(); 29 31 for(XmlCondition r: conditions) { 30 code += r.toCode();32 r.appendCode(sb); 31 33 } 34 code = sb.toString(); 32 35 } 33 36 } 34 37 return code; … … 41 44 for(XmlCondition r : conditions) 42 45 { 43 46 String k = primitive.get(r.key); 47 48 if (k == null || (r.value != null && !k.equals(r.value))) 49 return false; 50 44 51 String bv = OsmUtils.getNamedOsmBoolean(r.boolValue); 45 if(k == null || (r.value != null && !k.equals(r.value)) 46 || (bv != null && !bv.equals(OsmUtils.getNamedOsmBoolean(k))))52 53 if (bv != null && !bv.equals(OsmUtils.getNamedOsmBoolean(k))) 47 54 return false; 48 55 } 49 56 return true; -
src/org/openstreetmap/josm/gui/mappaint/xml/XmlCondition.java
37 37 { 38 38 return "Rule["+key+","+(boolValue != null ? "b="+boolValue:"v="+value)+"]"; 39 39 } 40 public String toCode() 40 41 public void appendCode(StringBuilder sb) 41 42 { 42 return "[k="+key+(boolValue != null ? ",b="+boolValue:",v="+value)+"]"; 43 sb.append("[k=").append(key); 44 45 if (boolValue != null) 46 sb.append(",b=").append(boolValue); 47 else 48 sb.append(",v=").append(value); 49 50 sb.append("]"); 43 51 } 44 52 }
