From ec036e8fe057f4b641ba9ee17d6dce2689816047 Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Fri, 14 Sep 2012 00:25:49 +1200 Subject: altoslib/altosui: begin moving preferences "backend" into interface Signed-off-by: Mike Beattie --- altoslib/AltosPreferencesBackend.java | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 altoslib/AltosPreferencesBackend.java (limited to 'altoslib/AltosPreferencesBackend.java') diff --git a/altoslib/AltosPreferencesBackend.java b/altoslib/AltosPreferencesBackend.java new file mode 100644 index 00000000..a8cfb31b --- /dev/null +++ b/altoslib/AltosPreferencesBackend.java @@ -0,0 +1,38 @@ +/* + * Copyright © 2010 Mike Beattie + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.AltosLib; + +public interface AltosPreferencesBackend { + + public String getString(String key, String def); + public void putString(String key, String value); + + public int getInt(String key, int def); + public void putInt(String key, int value); + + public double getDouble(String key, double def); + public void putDouble(String key, double value); + + public boolean getBoolean(String key, boolean def); + public void putBoolean(String key, boolean value); + + public boolean nodeExists(String key); + public AltosPreferencesBackend node(String key); + + public void flush(); +} -- cgit v1.2.3 From d875b459b5e9f7bcbbbbe318f947b0451ce6738f Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Fri, 14 Sep 2012 00:44:59 +1200 Subject: altosui/altoslib: add methods to interface, fix imports/exceptions in BT code Signed-off-by: Mike Beattie --- altoslib/AltosPreferencesBackend.java | 3 +++ altosui/AltosBTKnown.java | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'altoslib/AltosPreferencesBackend.java') diff --git a/altoslib/AltosPreferencesBackend.java b/altoslib/AltosPreferencesBackend.java index a8cfb31b..3fc4b0aa 100644 --- a/altoslib/AltosPreferencesBackend.java +++ b/altoslib/AltosPreferencesBackend.java @@ -34,5 +34,8 @@ public interface AltosPreferencesBackend { public boolean nodeExists(String key); public AltosPreferencesBackend node(String key); + public String[] keys(); + public void remove(String key); + public void flush(); } diff --git a/altosui/AltosBTKnown.java b/altosui/AltosBTKnown.java index 7e5e9533..ae04ac8c 100644 --- a/altosui/AltosBTKnown.java +++ b/altosui/AltosBTKnown.java @@ -17,7 +17,7 @@ package altosui; import java.util.*; -import java.util.prefs.*; +import org.altusmetrum.AltosLib.*; public class AltosBTKnown implements Iterable { LinkedList devices = new LinkedList(); @@ -43,7 +43,6 @@ public class AltosBTKnown implements Iterable { String addr = get_address(name); devices.add(new AltosBTDevice(name, addr)); } - } catch (BackingStoreException be) { } catch (IllegalStateException ie) { } } -- cgit v1.2.3