Changeset 3531 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2010-09-16T10:27:46+02:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r3530 r3531 601 601 synchronized private void putCollectionDefault(String key, Collection<String> val) { 602 602 String s = null; 603 if(val != null)603 for(String a : val) 604 604 { 605 for(String a : val) 606 { 607 if(s != null) { 608 s += "\u001e" + a; 609 } else { 610 s = a; 611 } 605 if(s != null) { 606 s += "\u001e" + a; 607 } else { 608 s = a; 612 609 } 613 610 } … … 616 613 synchronized public Collection<Collection<String>> getArray(String key, 617 614 Collection<Collection<String>> def) { 618 if(def != null) { 619 for(String k : getAllPrefixDefault(key + ".").keySet()) 620 put(k, null); 621 int num = 0; 622 for(Collection<String> c : def) 623 putCollectionDefault(key+"."+num++, c); 624 } 625 String s = get(key+".0"); 626 if(s != null && s.length() != 0) 627 { 628 Collection<Collection<String>> col = new LinkedList<Collection<String>>(); 629 for(int num = 0; ; ++num) { 630 Collection<String> c = getCollection(key+"."+num, null); 631 if(c == null) 632 break; 633 col.add(c); 634 } 635 return col; 636 } 637 return def; 615 if(def != null) 616 putArrayDefault(key, def); 617 key += "."; 618 int num = 0; 619 Collection<Collection<String>> col = new LinkedList<Collection<String>>(); 620 while(properties.containsKey(key+num)) 621 col.add(getCollection(key+num++, null)); 622 return num == 0 && def != null ? def : col; 638 623 } 639 624 synchronized public boolean putArray(String key, Collection<Collection<String>> val) { 640 625 boolean res = true; 626 key += "."; 641 627 Collection<String> keys = getAllPrefix(key).keySet(); 642 key += ".";643 628 if(val != null) { 644 String s = null;645 629 int num = 0; 646 630 for(Collection<String> c : val) { … … 661 645 } 662 646 647 synchronized private void putArrayDefault(String key, Collection<Collection<String>> val) { 648 key += "."; 649 Collection<String> keys = getAllPrefixDefault(key).keySet(); 650 int num = 0; 651 for(Collection<String> c : val) { 652 keys.remove(key+num); 653 putCollectionDefault(key+num++, c); 654 } 655 int l = key.length(); 656 for(String k : keys) { 657 try { 658 Integer.valueOf(k.substring(l)); 659 defaults.remove(k); 660 } catch(Exception e) { 661 } 662 } 663 } 664 663 665 /** 664 666 * Updates system properties with the current values in the preferences.
Note:
See TracChangeset
for help on using the changeset viewer.