Ignore:
Timestamp:
2017-09-14T02:25:27+02:00 (2 years ago)
Author:
bastiK
Message:

see #15229 - include support for the long type in IPreferences

Location:
trunk/src/org/openstreetmap/josm/spi/preferences
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/spi/preferences/AbstractPreferences.java

    r12847 r12853  
    5656    public boolean putInt(String key, int value) {
    5757        return put(key, Integer.toString(value));
     58    }
     59
     60    @Override
     61    public long getLong(String key, long def) {
     62        String v = get(key, Long.toString(def));
     63        if (null == v)
     64            return def;
     65
     66        try {
     67            return Long.parseLong(v);
     68        } catch (NumberFormatException e) {
     69            // fall out
     70            Logging.trace(e);
     71        }
     72        return def;
     73    }
     74
     75    @Override
     76    public boolean putLong(final String key, final long value) {
     77        return put(key, Long.toString(value));
    5878    }
    5979
  • trunk/src/org/openstreetmap/josm/spi/preferences/IPreferences.java

    r12847 r12853  
    105105
    106106    /**
    107      * Set a boolean value for a certain setting.
     107     * Set an integer value for a certain setting.
    108108     * @param key the unique identifier for the setting
    109109     * @param value The new value
     
    112112     */
    113113    boolean putInt(String key, int value);
     114
     115    /**
     116     * Gets a long preference
     117     * @param key The preference key
     118     * @param def The default value to use
     119     * @return The long value or the default value if it could not be parsed
     120     */
     121    long getLong(String key, long def);
     122
     123    /**
     124     * Set a long value for a certain setting.
     125     * @param key the unique identifier for the setting
     126     * @param value The new value
     127     * @return {@code true}, if something has changed (i.e. value is different than before)
     128     */
     129    boolean putLong(String key, long value);
    114130
    115131    /**
Note: See TracChangeset for help on using the changeset viewer.