summaryrefslogtreecommitdiff
path: root/src/user4574/texttransport/AndroidPersistence.java
blob: 66f9dd339b8e00b886a7b7565bc5a09782d3de7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package user4574.texttransport;

import java.util.Enumeration;
import java.util.HashMap;
import java.util.Vector;

import org.eclipse.paho.client.mqttv3.MqttClientPersistence;
import org.eclipse.paho.client.mqttv3.MqttPersistable;
import org.eclipse.paho.client.mqttv3.MqttPersistenceException;

public class AndroidPersistence implements MqttClientPersistence {
	
	private HashMap<String, MqttPersistable> store;
	
	public AndroidPersistence() {
		store = new HashMap<String, MqttPersistable>();
	}

	public void clear() throws MqttPersistenceException {
		store.clear();
	}

	public void close() throws MqttPersistenceException {
		store = null;
	}

	public boolean containsKey(String arg0) throws MqttPersistenceException {
		return store.containsKey(arg0);
	}

	public MqttPersistable get(String arg0) throws MqttPersistenceException {
		return store.get(arg0);
	}

	public Enumeration<String> keys() throws MqttPersistenceException {
		return new Vector<String>(store.keySet()).elements();
	}

	public void open(String arg0, String arg1) throws MqttPersistenceException {
		store = new HashMap<String, MqttPersistable>();
	}

	public void put(String arg0, MqttPersistable arg1) throws MqttPersistenceException {
		store.put(arg0, arg1);
	}

	public void remove(String arg0) throws MqttPersistenceException {
		store.remove(arg0);
	}
}