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