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.
20 import java.util.prefs.*;
21 import org.altusmetrum.AltosLib.*;
23 public class AltosUIPreferencesBackend implements AltosPreferencesBackend {
25 private Preferences _preferences = null;
27 public AltosUIPreferencesBackend() {
28 _preferences = Preferences.userRoot().node("/org/altusmetrum/altosui");
31 public AltosUIPreferencesBackend(Preferences in_preferences) {
32 _preferences = in_preferences;
35 public String getString(String key, String def) {
36 return _preferences.get(key, def);
38 public void putString(String key, String value) {
39 _preferences.put(key, value);
42 public int getInt(String key, int def) {
43 return _preferences.getInt(key, def);
45 public void putInt(String key, int value) {
46 _preferences.putInt(key, value);
49 public double getDouble(String key, double def) {
50 return _preferences.getDouble(key, def);
52 public void putDouble(String key, double value) {
53 _preferences.putDouble(key, value);
56 public boolean getBoolean(String key, boolean def) {
57 return _preferences.getBoolean(key, def);
59 public void putBoolean(String key, boolean value) {
60 _preferences.putBoolean(key, value);
63 public boolean nodeExists(String key) {
65 return _preferences.nodeExists(key);
66 } catch (BackingStoreException be) {
71 public AltosPreferencesBackend node(String key) {
72 return new AltosUIPreferencesBackend(_preferences.node(key));
75 public String[] keys() {
77 return _preferences.keys();
78 } catch (BackingStoreException be) {
83 public void remove(String key) {
84 _preferences.remove(key);
90 } catch (BackingStoreException ee) {
91 System.err.printf("Cannot save preferences\n");