altoslib: Remove spurious semicolon in AltosReplayReader.java
[fw/altos] / altoslib / AltosPreferencesBackend.java
1 /*
2  * Copyright © 2010 Mike Beattie <mike@ethernal.org>
3  *
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; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18
19 package org.altusmetrum.altoslib_12;
20
21 import java.io.*;
22 import java.util.*;
23 import java.text.*;
24
25 public abstract class AltosPreferencesBackend {
26
27         public abstract String  getString(String key, String def);
28         public abstract void    putString(String key, String value);
29
30         public abstract int     getInt(String key, int def);
31         public abstract void    putInt(String key, int value);
32
33         public abstract double  getDouble(String key, double def);
34         public abstract void    putDouble(String key, double value);
35
36         public abstract boolean getBoolean(String key, boolean def);
37         public abstract void    putBoolean(String key, boolean value);
38
39         public abstract byte[]  getBytes(String key, byte[] def);
40         public abstract void    putBytes(String key, byte[] value);
41
42         public AltosJson        getJson(String key) {
43                 String  value = getString(key, null);
44
45                 if (value == null)
46                         return null;
47                 try {
48                         return AltosJson.fromString(value);
49                 } catch (IllegalArgumentException ie) {
50                         return null;
51                 }
52         }
53
54         public void             putJson(String key, AltosJson j) {
55                 putString(key, j.toString());
56         }
57
58         public abstract boolean nodeExists(String key);
59         public abstract AltosPreferencesBackend node(String key);
60
61         public abstract String[] keys();
62         public abstract void    remove(String key);
63
64         public abstract void    flush();
65
66         public abstract File homeDirectory();
67
68         public abstract void debug(String format, Object ... arguments);
69 }