Ignore:
Timestamp:
2010-12-08T22:33:58+01:00 (13 years ago)
Author:
bastiK
Message:

slight change in preference: getCollection(key, def) always remembers default, even if def == null (to be consistent with get(key, def). (this shouldn't break anything, but you never know...)

File:
1 edited

Legend:

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

    r3708 r3709  
    616616    }
    617617
     618    /**
     619     * Get a list of values for a certain key
     620     * @param key the identifier for the setting
     621     * @param def the default value.
     622     * @return the corresponding value if the property has been set before,
     623     *  def otherwise
     624     */
    618625    synchronized public Collection<String> getCollection(String key, Collection<String> def) {
     626        putCollectionDefault(key, def);
    619627        String s = get(key);
    620         if(def != null)
    621             putCollectionDefault(key, def);
    622628        if(s != null && s.length() != 0)
    623629            return Arrays.asList(s.split("\u001e"));
     
    651657   
    652658    synchronized private void putCollectionDefault(String key, Collection<String> val) {
    653         String s = null;
    654         for(String a : val)
    655         {
    656             if(s != null) {
    657                 s += "\u001e" + a;
    658             } else {
    659                 s = a;
    660             }
    661         }
    662         putDefault(key, s);
     659        if (val == null) {
     660            putDefault(key, null);
     661        } else {
     662            String s = null;
     663            for(String a : val)
     664            {
     665                if(s != null) {
     666                    s += "\u001e" + a;
     667                } else {
     668                    s = a;
     669                }
     670            }
     671            putDefault(key, s);
     672        }
    663673    }
    664674   
Note: See TracChangeset for help on using the changeset viewer.