projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altoslib: Create new abstraction underneath AltosState for recording values
[fw/altos]
/
altoslib
/
AltosPreferencesBackend.java
diff --git
a/altoslib/AltosPreferencesBackend.java
b/altoslib/AltosPreferencesBackend.java
index 9f2e8f7c9541bf0945fd9291ca37701181fedc44..327b534c05fa0155cf4099a805d2bb9023f74ea1 100644
(file)
--- a/
altoslib/AltosPreferencesBackend.java
+++ b/
altoslib/AltosPreferencesBackend.java
@@
-3,7
+3,8
@@
*
* 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
*
* 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.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
@@
-15,36
+16,54
@@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-package org.altusmetrum.altoslib_1
0
;
+package org.altusmetrum.altoslib_1
1
;
-import java.io.File;
+import java.io.*;
+import java.util.*;
+import java.text.*;
-public
interface
AltosPreferencesBackend {
+public
abstract class
AltosPreferencesBackend {
- public String getString(String key, String def);
- public void putString(String key, String value);
+ public
abstract
String getString(String key, String def);
+ public
abstract
void putString(String key, String value);
- public int getInt(String key, int def);
- public void putInt(String key, int value);
+ public
abstract
int getInt(String key, int def);
+ public
abstract
void putInt(String key, int value);
- public double getDouble(String key, double def);
- public void putDouble(String key, double value);
+ public
abstract
double getDouble(String key, double def);
+ public
abstract
void putDouble(String key, double value);
- public boolean getBoolean(String key, boolean def);
- public void putBoolean(String key, boolean value);
+ public
abstract
boolean getBoolean(String key, boolean def);
+ public
abstract
void putBoolean(String key, boolean value);
- public byte[] getBytes(String key, byte[] def);
- public void putBytes(String key, byte[] value);
+ public
abstract
byte[] getBytes(String key, byte[] def);
+ public
abstract
void putBytes(String key, byte[] value);
- public
boolean nodeExists(String key);
-
public AltosPreferencesBackend node(String key
);
+ public
AltosJson getJson(String key) {
+
String value = getString(key, null
);
- public String[] keys();
- public void remove(String key);
+ if (value == null)
+ return null;
+ try {
+ return AltosJson.fromString(value);
+ } catch (IllegalArgumentException ie) {
+ return null;
+ }
+ }
- public void flush();
+ public void putJson(String key, AltosJson j) {
+ putString(key, j.toString());
+ }
- public File homeDirectory();
+ public abstract boolean nodeExists(String key);
+ public abstract AltosPreferencesBackend node(String key);
- public void debug(String format, Object ... arguments);
+ public abstract String[] keys();
+ public abstract void remove(String key);
+
+ public abstract void flush();
+
+ public abstract File homeDirectory();
+
+ public abstract void debug(String format, Object ... arguments);
}
}