| 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 | 1 | super(peer); |
| 26 | 1 | } |
| 27 | |
|
| 28 | |
public boolean getBoolean(String key) throws NoSuchElementException |
| 29 | |
{ |
| 30 | 1 | return Boolean.valueOf(get(key)); |
| 31 | |
} |
| 32 | |
|
| 33 | |
public byte[] getByteArray(String key) throws NoSuchElementException |
| 34 | |
{ |
| 35 | 1 | byte[] value = getByteArray(key, null); |
| 36 | |
|
| 37 | 1 | if (value == null) |
| 38 | |
{ |
| 39 | 1 | throw new NoSuchElementException(); |
| 40 | |
} |
| 41 | |
|
| 42 | 0 | return value; |
| 43 | |
} |
| 44 | |
|
| 45 | |
public double getDouble(String key) throws NoSuchElementException |
| 46 | |
{ |
| 47 | 1 | return Double.parseDouble(get(key)); |
| 48 | |
} |
| 49 | |
|
| 50 | |
public float getFloat(String key) throws NoSuchElementException |
| 51 | |
{ |
| 52 | 1 | return Float.parseFloat(get(key)); |
| 53 | |
} |
| 54 | |
|
| 55 | |
public int getInt(String key) throws NoSuchElementException |
| 56 | |
{ |
| 57 | 1 | return Integer.parseInt(get(key)); |
| 58 | |
} |
| 59 | |
|
| 60 | |
public long getLong(String key) throws NoSuchElementException |
| 61 | |
{ |
| 62 | 1 | return Long.parseLong(get(key)); |
| 63 | |
} |
| 64 | |
|
| 65 | |
public String get(String key) throws NoSuchElementException |
| 66 | |
{ |
| 67 | 7 | String value = get(key, null); |
| 68 | |
|
| 69 | 7 | if (value == null) |
| 70 | |
{ |
| 71 | 6 | throw new NoSuchElementException(); |
| 72 | |
} |
| 73 | |
|
| 74 | 1 | return value; |
| 75 | |
} |
| 76 | |
} |