Changeset 3149 in josm for trunk


Ignore:
Timestamp:
2010-03-20T12:02:36+01:00 (15 years ago)
Author:
jttt
Message:

Do not allow zero length arrays for OsmPrimitive.keys

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r3129 r3149  
    701701    public void setKeys(Map<String, String> keys) {
    702702        Map<String, String> originalKeys = getKeys();
    703         if (keys == null) {
     703        if (keys == null || keys.isEmpty()) {
    704704            this.keys = null;
    705705            keysChangedImpl(originalKeys);
     
    731731        else if (value == null) {
    732732            remove(key);
    733         } else if (keys == null || keys.length == 0){
     733        } else if (keys == null){
    734734            keys = new String[] {key, value};
    735735            keysChangedImpl(originalKeys);
     
    759759     */
    760760    public final void remove(String key) {
    761         if (key == null || keys == null || keys.length == 0 ) return;
     761        if (key == null || keys == null) return;
    762762        if (!hasKey(key))
    763763            return;
     
    803803        if (key == null)
    804804            return null;
    805         if (keys == null || keys.length == 0)
     805        if (keys == null)
    806806            return null;
    807807        for (int i=0; i<keys.length;i+=2) {
     
    812812
    813813    public final Collection<String> keySet() {
    814         if (keys == null || keys.length == 0)
     814        if (keys == null)
    815815            return Collections.emptySet();
    816816        Set<String> result = new HashSet<String>(keys.length / 2);
     
    828828     */
    829829    public final boolean hasKeys() {
    830         return keys != null && keys.length != 0;
     830        return keys != null;
    831831    }
    832832
Note: See TracChangeset for help on using the changeset viewer.