1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.commons.settings;
21
22 /***
23 * @author Steffen Pingel
24 */
25 public class IntSetting extends AbstractSetting<Integer> {
26
27 public IntSetting(SettingResource backend, String key, Integer defaultValue, int min, int max)
28 {
29 super(backend, key, defaultValue, new IntValidator(min, max));
30 }
31
32 public IntSetting(SettingResource backend, String key, Integer defaultValue, int min)
33 {
34 super(backend, key, defaultValue, new IntValidator(min));
35 }
36
37 public IntSetting(SettingResource backend, String key, Integer defaultValue, Validator validator)
38 {
39 super(backend, key, defaultValue, validator);
40 }
41
42 public IntSetting(SettingResource backend, String key, Integer defaultValue)
43 {
44 super(backend, key, defaultValue, null);
45 }
46
47 protected Integer fromString(String value)
48 {
49 try {
50 return new Integer(value);
51 }
52 catch (NumberFormatException e) {
53 return null;
54 }
55 }
56
57 protected String toString(Integer value)
58 {
59 return value.toString();
60 }
61
62 }