Changeset 2906 in josm


Ignore:
Timestamp:
Jan 29, 2010 10:26:58 PM (3 years ago)
Author:
mjulius
Message:

remove OsmPrimitive.entrySet()
using keySet()/get() or getKeys() instead

Location:
trunk/src/org/openstreetmap/josm
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java

    r2842 r2906  
    250250        ways.add(b); 
    251251 
    252         // This is mostly copied and pasted from CombineWayAction.java and one day should be moved into tools 
     252        // FIXME: This is mostly copied and pasted from CombineWayAction.java and one day should be moved into tools 
    253253        Map<String, Set<String>> props = new TreeMap<String, Set<String>>(); 
    254254        for (Way w : ways) { 
    255             for (Entry<String,String> e : w.entrySet()) { 
    256                 if (!props.containsKey(e.getKey())) { 
    257                     props.put(e.getKey(), new TreeSet<String>()); 
    258                 } 
    259                 props.get(e.getKey()).add(e.getValue()); 
     255            for (String key: w.keySet()) { 
     256                if (!props.containsKey(key)) { 
     257                    props.put(key, new TreeSet<String>()); 
     258                } 
     259                props.get(key).add(w.get(key)); 
    260260            } 
    261261        } 
  • trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java

    r2863 r2906  
    77import java.io.PushbackReader; 
    88import java.io.StringReader; 
    9 import java.util.Map.Entry; 
    109import java.util.regex.Matcher; 
    1110import java.util.regex.Pattern; 
     
    194193                 */ 
    195194 
    196                 for (Entry<String, String> e : osm.entrySet()) { 
    197                     String k = e.getKey(); 
    198                     String v = e.getValue(); 
     195                for (String k: osm.keySet()) { 
     196                    String v = osm.get(k); 
    199197 
    200198                    Matcher matcherKey = keyPattern.matcher(k); 
     
    330328            case ANY_VALUE_REGEXP: 
    331329            case EXACT_REGEXP: 
    332                 for (Entry<String, String> entry:osm.entrySet()) { 
    333                     if (keyPattern.matcher(entry.getKey()).matches()) { 
     330                for (String key: osm.keySet()) { 
     331                    if (keyPattern.matcher(key).matches()) { 
    334332                        if (mode == Mode.ANY_VALUE_REGEXP 
    335                                 || valuePattern.matcher(entry.getValue()).matches()) 
     333                                || valuePattern.matcher(osm.get(key)).matches()) 
    336334                            return true; 
    337335                    } 
     
    384382            // is not Java 1.5 
    385383            //search = java.text.Normalizer.normalize(search, java.text.Normalizer.Form.NFC); 
    386             for (Entry<String, String> e : osm.entrySet()) { 
     384            for (String key: osm.keySet()) { 
     385                String value = osm.get(key); 
    387386                if (searchRegex != null) { 
    388                     String key = e.getKey(); 
    389                     String value = e.getValue(); 
    390387 
    391388                    // is not Java 1.5 
     
    401398                        return true; 
    402399                } else { 
    403                     String key = caseSensitive ? e.getKey() : e.getKey().toLowerCase(); 
    404                     String value = caseSensitive ? e.getValue() : e.getValue().toLowerCase(); 
     400                    if (caseSensitive) { 
     401                        key = key.toLowerCase(); 
     402                        value = value.toLowerCase(); 
     403                    } 
    405404 
    406405                    // is not Java 1.5 
  • trunk/src/org/openstreetmap/josm/actions/upload/ApiPreconditionCheckerHook.java

    r2641 r2906  
    55import java.util.Collection; 
    66import java.util.Collections; 
    7 import java.util.Map.Entry; 
    87 
    98import javax.swing.JOptionPane; 
     
    5049    private boolean checkMaxNodes(Collection<OsmPrimitive> primitives, long maxNodes) { 
    5150        for (OsmPrimitive osmPrimitive : primitives) { 
    52             for (Entry<String,String> e : osmPrimitive.entrySet()) { 
    53                 if(e.getValue().length() > 255) { 
     51            for (String key: osmPrimitive.keySet()) { 
     52                String value = osmPrimitive.get(key); 
     53                if(key.length() > 255) { 
    5454                    if (osmPrimitive.isDeleted()) { 
    5555                        // if OsmPrimitive is going to be deleted we automatically shorten the 
     
    5757                        System.out.println( 
    5858                                tr("Warning: automatically truncating value of tag ''{0}'' on deleted object {1}", 
    59                                         e.getKey(), 
     59                                        key, 
    6060                                        Long.toString(osmPrimitive.getId()) 
    6161                                ) 
    6262                        ); 
    63                         osmPrimitive.put(e.getKey(), e.getValue().substring(0, 255)); 
     63                        osmPrimitive.put(key, value.substring(0, 255)); 
    6464                        continue; 
    6565                    } 
    6666                    JOptionPane.showMessageDialog(Main.parent, 
    6767                            tr("Length of value for tag ''{0}'' on object {1} exceeds the max. allowed length {2}. Values length is {3}.", 
    68                                     e.getKey(), Long.toString(osmPrimitive.getId()), 255, e.getValue().length() 
     68                                    key, Long.toString(osmPrimitive.getId()), 255, value.length() 
    6969                            ), 
    7070                            tr("Precondition Violation"), 
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r2903 r2906  
    4747    } 
    4848 
    49     private static class KeysEntry implements Entry<String, String>{ 
    50  
    51         private final String key; 
    52         private final String value; 
    53  
    54         private KeysEntry(String key, String value) { 
    55             this.key = key; 
    56             this.value = value; 
    57         } 
    58  
    59         public String getKey() { 
    60             return key; 
    61         } 
    62  
    63         public String getValue() { 
    64             return value; 
    65         } 
    66  
    67         public String setValue(String value) { 
    68             throw new UnsupportedOperationException(); 
    69         } 
    70  
    71         @Override 
    72         public int hashCode() { 
    73             final int prime = 31; 
    74             int result = 1; 
    75             result = prime * result + ((key == null) ? 0 : key.hashCode()); 
    76             result = prime * result + ((value == null) ? 0 : value.hashCode()); 
    77             return result; 
    78         } 
    79  
    80         @Override 
    81         public boolean equals(Object obj) { 
    82             if (this == obj) 
    83                 return true; 
    84             if (obj == null) 
    85                 return false; 
    86             if (getClass() != obj.getClass()) 
    87                 return false; 
    88             KeysEntry other = (KeysEntry) obj; 
    89             if (key == null) { 
    90                 if (other.key != null) 
    91                     return false; 
    92             } else if (!key.equals(other.key)) 
    93                 return false; 
    94             if (value == null) { 
    95                 if (other.value != null) 
    96                     return false; 
    97             } else if (!value.equals(other.value)) 
    98                 return false; 
    99             return true; 
    100         } 
    101     } 
    102  
    10349    private static final int FLAG_MODIFIED = 1 << 0; 
    10450    private static final int FLAG_VISIBLE  = 1 << 1; 
     
    556502        // FIXME: incline=\"-*\" search pattern does not work. 
    557503        String reversedDirectionDefault = "oneway=\"-1\" | incline=down | incline=\"-*\""; 
    558          
     504 
    559505        String directionDefault = "oneway? | incline=* | aerialway=* | "+ 
    560                                   "waterway=stream | waterway=river | waterway=canal | waterway=drain | waterway=rapids | "+ 
    561                                   "\"piste:type\"=downhill | \"piste:type\"=sled | man_made=\"piste:halfpipe\" | "+ 
    562                                   "junction=roundabout"; 
     506        "waterway=stream | waterway=river | waterway=canal | waterway=drain | waterway=rapids | "+ 
     507        "\"piste:type\"=downhill | \"piste:type\"=sled | man_made=\"piste:halfpipe\" | "+ 
     508        "junction=roundabout"; 
    563509 
    564510        try { 
     
    846792    } 
    847793 
    848     // FIXME: why replying a collection of entries? Should be replaced by 
    849     // a method Map<String,String> getTags() 
    850     // 
    851     public final Collection<Entry<String, String>> entrySet() { 
    852         if (keys == null || keys.length ==0) 
    853             return Collections.emptySet(); 
    854         Set<Entry<String, String>> result = new HashSet<Entry<String,String>>(); 
    855         for (int i=0; i<keys.length; i+=2) { 
    856             result.add(new KeysEntry(keys[i], keys[i+1])); 
    857         } 
    858         return result; 
    859     } 
    860  
    861794    public final Collection<String> keySet() { 
    862795        if (keys == null || keys.length == 0) 
     
    910843     */ 
    911844    public boolean hasSameTags(OsmPrimitive other) { 
    912         return entrySet().equals(other.entrySet()); 
     845        return keySet().equals(other.keySet()); 
    913846    } 
    914847 
  • trunk/src/org/openstreetmap/josm/gui/MapStatus.java

    r2871 r2906  
    2929import java.util.ConcurrentModificationException; 
    3030import java.util.List; 
    31 import java.util.Map.Entry; 
    3231 
    3332import javax.swing.BorderFactory; 
     
    436435            } 
    437436 
    438             for (Entry<String, String> e1 : osm.entrySet()) { 
    439                 text.append("<br>" + e1.getKey() + "=" + e1.getValue()); 
     437            for (String key : osm.keySet()) { 
     438                text.append("<br>" + key + "=" + osm.get(key)); 
    440439            } 
    441440 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/ListOfUsedTags.java

    r2711 r2906  
    7070 
    7171    private void addPrimitive(OsmPrimitive primitive) { 
    72         for (Entry<String, String> entry: primitive.entrySet()) { 
    73             addKey(entry.getKey(), entry.getValue()); 
     72        for (String key: primitive.keySet()) { 
     73            addKey(key, primitive.get(key)); 
    7474        } 
    7575    } 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r2869 r2906  
    729729                ++ways; 
    730730            } 
    731             for (Entry<String, String> e : osm.entrySet()) { 
    732                 keyCount.put(e.getKey(), keyCount.containsKey(e.getKey()) ? keyCount.get(e.getKey())+1 : 1); 
    733                 if (valueCount.containsKey(e.getKey())) { 
    734                     Map<String, Integer> v = valueCount.get(e.getKey()); 
    735                     v.put(e.getValue(), v.containsKey(e.getValue())? v.get(e.getValue())+1 : 1 ); 
     731            for (String key: osm.keySet()) { 
     732                String value = osm.get(key); 
     733                keyCount.put(key, keyCount.containsKey(key) ? keyCount.get(key) + 1 : 1); 
     734                if (valueCount.containsKey(key)) { 
     735                    Map<String, Integer> v = valueCount.get(key); 
     736                    v.put(value, v.containsKey(value)? v.get(value) + 1 : 1 ); 
    736737                } else { 
    737738                    TreeMap<String,Integer> v = new TreeMap<String, Integer>(); 
    738                     v.put(e.getValue(), 1); 
    739                     valueCount.put(e.getKey(), v); 
     739                    v.put(value, 1); 
     740                    valueCount.put(key, v); 
    740741                } 
    741742            } 
  • trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java

    r2626 r2906  
    77import java.util.LinkedList; 
    88import java.util.List; 
    9 import java.util.Map.Entry; 
    109 
    1110import org.openstreetmap.josm.Main; 
     
    4039        { 
    4140            IconElemStyle ret = null; 
    42             for (Entry<String, String> entry:primitive.entrySet()) { 
    43                 String key = entry.getKey(); 
    44                 String val = entry.getValue(); 
     41            for (String key: primitive.keySet()) { 
     42                String val = primitive.get(key); 
    4543                IconElemStyle style; 
    4644                if((style = icons.get("n" + key + "=" + val)) != null) 
     
    7775            String linestring = null; 
    7876            HashMap<String, LineElemStyle> over = new HashMap<String, LineElemStyle>(); 
    79             for (Entry<String, String> entry:primitive.entrySet()) { 
    80                 String key = entry.getKey(); 
    81                 String val = entry.getValue(); 
     77            for (String key: primitive.keySet()) { 
     78                String val = primitive.get(key); 
    8279                AreaElemStyle styleArea; 
    8380                LineElemStyle styleLine; 
Note: See TracChangeset for help on using the changeset viewer.