-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test with java prefs api // refs #41
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/de/paginagmbh/epubchecker/PreferenceManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package de.paginagmbh.epubchecker; | ||
|
||
import java.util.prefs.BackingStoreException; | ||
import java.util.prefs.Preferences; | ||
|
||
|
||
public class PreferenceManager { | ||
|
||
private static String prefsNode = "de/paginagmbh/epubchecker"; | ||
public enum Preference { | ||
WINDOWPOSITION; | ||
} | ||
|
||
public static String getPref(Preference pref) { | ||
Preferences prefs = Preferences.userRoot().node(prefsNode); | ||
return prefs.get(pref.toString().toLowerCase(), null); | ||
} | ||
|
||
public static void savePref(Preference pref, String value) { | ||
Preferences prefs = Preferences.userRoot().node(prefsNode); | ||
prefs.put(pref.toString().toLowerCase(), value); | ||
try { | ||
prefs.flush(); | ||
} catch (BackingStoreException e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |