Last change
on this file since 4067 was 3730, checked in by bastiK, 13 years ago |
improve migration when remotecontrol plugin is removed (set remotecontol.enabled=yes) (see also #5748)
|
-
Property svn:eol-style
set to
native
-
Property svn:mime-type
set to
text/plain
|
File size:
1.1 KB
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.preferences;
|
---|
3 |
|
---|
4 | import org.openstreetmap.josm.Main;
|
---|
5 |
|
---|
6 | public class IntegerProperty extends AbstractProperty {
|
---|
7 |
|
---|
8 | protected final int defaultValue;
|
---|
9 |
|
---|
10 | public IntegerProperty(String key, int defaultValue) {
|
---|
11 | super(key);
|
---|
12 | this.defaultValue = defaultValue;
|
---|
13 | }
|
---|
14 |
|
---|
15 | public int get() {
|
---|
16 | return Main.pref.getInteger(getKey(), getDefaultValue());
|
---|
17 | }
|
---|
18 |
|
---|
19 | public boolean put(int value) {
|
---|
20 | return Main.pref.putInteger(getKey(), value);
|
---|
21 | }
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * parses and saves an integer value
|
---|
25 | * @param value the value to be parsed
|
---|
26 | * @return true - preference value has changed
|
---|
27 | * false - parsing failed or preference value has not changed
|
---|
28 | */
|
---|
29 | public boolean parseAndPut(String value) {
|
---|
30 | Integer intVal;
|
---|
31 | try {
|
---|
32 | intVal = Integer.parseInt(value);
|
---|
33 | } catch (NumberFormatException ex) {
|
---|
34 | return false;
|
---|
35 | }
|
---|
36 | return put(intVal);
|
---|
37 | }
|
---|
38 |
|
---|
39 | public int getDefaultValue() {
|
---|
40 | return defaultValue;
|
---|
41 | }
|
---|
42 |
|
---|
43 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.