1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| package org.ini4j.addon; |
18 |
| |
19 |
| import java.util.NoSuchElementException; |
20 |
| import java.util.prefs.Preferences; |
21 |
| |
22 |
| public class StrictPreferences extends PreferencesWrapper |
23 |
| { |
24 |
1
| public StrictPreferences(Preferences peer)
|
25 |
| { |
26 |
1
| super(peer);
|
27 |
| } |
28 |
| |
29 |
7
| public String get(String key) throws NoSuchElementException
|
30 |
| { |
31 |
7
| String value = get(key, null);
|
32 |
| |
33 |
7
| if ( value == null )
|
34 |
| { |
35 |
6
| throw new NoSuchElementException();
|
36 |
| } |
37 |
| |
38 |
1
| return value;
|
39 |
| } |
40 |
| |
41 |
1
| public int getInt(String key) throws NoSuchElementException
|
42 |
| { |
43 |
1
| return Integer.parseInt(get(key));
|
44 |
| } |
45 |
| |
46 |
1
| public long getLong(String key) throws NoSuchElementException
|
47 |
| { |
48 |
1
| return Long.parseLong(get(key));
|
49 |
| } |
50 |
| |
51 |
1
| public boolean getBoolean(String key) throws NoSuchElementException
|
52 |
| { |
53 |
1
| return Boolean.valueOf(get(key));
|
54 |
| } |
55 |
| |
56 |
1
| public float getFloat(String key) throws NoSuchElementException
|
57 |
| { |
58 |
1
| return Float.parseFloat(get(key));
|
59 |
| } |
60 |
| |
61 |
1
| public double getDouble(String key) throws NoSuchElementException
|
62 |
| { |
63 |
1
| return Double.parseDouble(get(key));
|
64 |
| } |
65 |
| |
66 |
1
| public byte[] getByteArray(String key) throws NoSuchElementException
|
67 |
| { |
68 |
1
| byte[] value = getByteArray(key, null);
|
69 |
| |
70 |
1
| if ( value == null )
|
71 |
| { |
72 |
1
| throw new NoSuchElementException();
|
73 |
| } |
74 |
| |
75 |
0
| return value;
|
76 |
| } |
77 |
| } |