Changeset 343 in josm for trunk/src/org/openstreetmap/josm/data/Preferences.java
- Timestamp:
- 2007-10-07T13:20:27+02:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/Preferences.java
r298 r343 54 54 55 55 /** 56 * Override some values on read. This is intended to be used for technology previews 57 * where we want to temporarily modify things without changing the user's preferences 58 * file. 59 */ 60 protected static final SortedMap<String, String> override = new TreeMap<String, String>(); 61 static { 62 override.put("osm-server.version", "0.5"); 63 override.put("osm-server.additional-versions", ""); 64 override.put("osm-server.url", "http://openstreetmap.gryph.de/api"); 65 override.put("osm-server.username", "fred@remote.org"); 66 override.put("osm-server.password", "fredfred"); 67 override.put("plugins", null); 68 } 69 70 /** 56 71 * Return the location of the user defined preferences file 57 72 */ … … 63 78 64 79 /** 65 * @return A list of all existing directories, where res sources could be stored.80 * @return A list of all existing directories, where resources could be stored. 66 81 */ 67 82 public Collection<String> getAllPossiblePreferenceDirs() { … … 93 108 94 109 synchronized public boolean hasKey(final String key) { 95 return properties.containsKey(key);110 return override.containsKey(key) ? override.get(key) != null : properties.containsKey(key); 96 111 } 97 112 synchronized public String get(final String key) { 113 if (override.containsKey(key)) 114 return override.get(key); 98 115 if (!properties.containsKey(key)) 99 116 return ""; … … 101 118 } 102 119 synchronized public String get(final String key, final String def) { 120 if (override.containsKey(key)) 121 return override.get(key); 103 122 final String prop = properties.get(key); 104 123 if (prop == null || prop.equals("")) … … 111 130 if (e.getKey().startsWith(prefix)) 112 131 all.put(e.getKey(), e.getValue()); 132 for (final Entry<String,String> e : override.entrySet()) 133 if (e.getKey().startsWith(prefix)) 134 if (e.getValue() == null) 135 all.remove(e.getKey()); 136 else 137 all.put(e.getKey(), e.getValue()); 113 138 return all; 114 139 } … … 117 142 } 118 143 synchronized public boolean getBoolean(final String key, final boolean def) { 144 if (override.containsKey(key)) 145 return override.get(key) == null ? def : Boolean.parseBoolean(override.get(key)); 119 146 return properties.containsKey(key) ? Boolean.parseBoolean(properties.get(key)) : def; 120 147 } … … 148 175 try { 149 176 final PrintWriter out = new PrintWriter(new FileWriter(getPreferencesDir() + "preferences"), false); 150 for (final Entry<String, String> e : properties.entrySet()) 177 for (final Entry<String, String> e : properties.entrySet()) { 151 178 if (!e.getValue().equals("")) 152 179 out.println(e.getKey() + "=" + e.getValue()); 180 } 153 181 out.close(); 154 182 } catch (final IOException e) {
Note:
See TracChangeset
for help on using the changeset viewer.