Ignore:
Timestamp:
2007-10-07T13:20:27+02:00 (17 years ago)
Author:
gebner
Message:

Merge 0.5.

File:
1 edited

Legend:

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

    r298 r343  
    5454
    5555        /**
     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        /**
    5671         * Return the location of the user defined preferences file
    5772         */
     
    6378
    6479        /**
    65          * @return A list of all existing directories, where ressources could be stored.
     80         * @return A list of all existing directories, where resources could be stored.
    6681         */
    6782        public Collection<String> getAllPossiblePreferenceDirs() {
     
    93108
    94109        synchronized public boolean hasKey(final String key) {
    95                 return properties.containsKey(key);
     110                return override.containsKey(key) ? override.get(key) != null : properties.containsKey(key);
    96111        }
    97112        synchronized public String get(final String key) {
     113                if (override.containsKey(key))
     114                        return override.get(key);
    98115                if (!properties.containsKey(key))
    99116                        return "";
     
    101118        }
    102119        synchronized public String get(final String key, final String def) {
     120                if (override.containsKey(key))
     121                        return override.get(key);
    103122                final String prop = properties.get(key);
    104123                if (prop == null || prop.equals(""))
     
    111130                        if (e.getKey().startsWith(prefix))
    112131                                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());
    113138                return all;
    114139        }
     
    117142        }
    118143        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));
    119146                return properties.containsKey(key) ? Boolean.parseBoolean(properties.get(key)) : def;
    120147        }
     
    148175                try {
    149176                        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()) {
    151178                                if (!e.getValue().equals(""))
    152179                                        out.println(e.getKey() + "=" + e.getValue());
     180                        }
    153181                        out.close();
    154182                } catch (final IOException e) {
Note: See TracChangeset for help on using the changeset viewer.