2 * Copyright © 2012 Mike Beattie <mike@ethernal.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 import java.util.prefs.*;
22 import org.altusmetrum.AltosLib.*;
24 public class AltosUIPreferencesBackend implements AltosPreferencesBackend {
26 private Preferences _preferences = null;
28 public AltosUIPreferencesBackend() {
29 _preferences = Preferences.userRoot().node("/org/altusmetrum/altosui");
32 public AltosUIPreferencesBackend(Preferences in_preferences) {
33 _preferences = in_preferences;
36 public String getString(String key, String def) {
37 return _preferences.get(key, def);
39 public void putString(String key, String value) {
40 _preferences.put(key, value);
43 public int getInt(String key, int def) {
44 return _preferences.getInt(key, def);
46 public void putInt(String key, int value) {
47 _preferences.putInt(key, value);
50 public double getDouble(String key, double def) {
51 return _preferences.getDouble(key, def);
53 public void putDouble(String key, double value) {
54 _preferences.putDouble(key, value);
57 public boolean getBoolean(String key, boolean def) {
58 return _preferences.getBoolean(key, def);
60 public void putBoolean(String key, boolean value) {
61 _preferences.putBoolean(key, value);
64 public boolean nodeExists(String key) {
66 return _preferences.nodeExists(key);
67 } catch (BackingStoreException be) {
72 public AltosPreferencesBackend node(String key) {
73 return new AltosUIPreferencesBackend(_preferences.node(key));
76 public String[] keys() {
77 return _preferences.keys();
80 public void remove(String key) {
81 _preferences.remove(key);
87 } catch (BackingStoreException ee) {
88 System.err.printf("Cannot save preferences\n");