public class MqttDefaultFilePersistence extends Object implements MqttClientPersistence
MqttClientPersistence interface that provides
file based persistence.
A directory is specified when the Persistence object is created. When the persistence
is then opened (see open(String, String)), a sub-directory is made beneath the base
for this client ID and connection key. This allows one persistence base directory
to be shared by multiple clients.
The sub-directory's name is created from a concatenation of the client ID and connection key
with any instance of '/', '\\', ':' or ' ' removed.| Constructor and Description |
|---|
MqttDefaultFilePersistence() |
MqttDefaultFilePersistence(String directory)
Create an file-based persistent data store within the specified directory.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears persistence, so that it no longer contains any persisted data.
|
void |
close()
Close the persistent store that was previously opened.
|
boolean |
containsKey(String key)
Returns whether or not data is persisted using the specified key.
|
MqttPersistable |
get(String key)
Gets the specified data out of the persistent store.
|
Enumeration |
keys()
Returns all of the persistent data from the previously specified persistence directory.
|
void |
open(String clientId,
String theConnection)
Initialise the persistent store.
|
void |
put(String key,
MqttPersistable message)
Writes the specified persistent data to the previously specified persistence directory.
|
void |
remove(String key)
Deletes the data with the specified key from the previously specified persistence directory.
|
public MqttDefaultFilePersistence()
public MqttDefaultFilePersistence(String directory)
directory - the directory to use.public void open(String clientId, String theConnection) throws MqttPersistenceException
MqttClientPersistenceopen in interface MqttClientPersistenceclientId - The client for which the persistent store should be opened.theConnection - The connection string as specified when the MQTT client instance was created.MqttPersistenceException - if there was a problem opening the persistent store.public void close()
throws MqttPersistenceException
MqttClientPersistenceclose in interface MqttClientPersistenceMqttPersistenceExceptionpublic void put(String key, MqttPersistable message) throws MqttPersistenceException
put in interface MqttClientPersistencemessage - key - the key for the data, which will be used later to retrieve it.MqttPersistenceExceptionpublic MqttPersistable get(String key) throws MqttPersistenceException
MqttClientPersistenceget in interface MqttClientPersistencekey - the key for the data, which was used when originally saving it.MqttPersistenceException - if there was a problem getting the data
from the persistent store.public void remove(String key) throws MqttPersistenceException
remove in interface MqttClientPersistenceMqttPersistenceExceptionpublic Enumeration keys() throws MqttPersistenceException
keys in interface MqttClientPersistenceMqttPersistenceExceptionpublic boolean containsKey(String key) throws MqttPersistenceException
MqttClientPersistencecontainsKey in interface MqttClientPersistencekey - the key for data, which was used when originally saving it.MqttPersistenceExceptionpublic void clear()
throws MqttPersistenceException
MqttClientPersistenceclear in interface MqttClientPersistenceMqttPersistenceExceptionCopyright © 2017 Eclipse Paho. All Rights Reserved.