public class LocalStorageHelper
extends java.lang.Object
Constructor and Description |
---|
LocalStorageHelper(java.lang.String persistenceDirectory,
java.lang.String containerActorName)
Construct a LocalStorageHelper using the container's name and the actors'
display name for the directory name.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Remove all keys in the local storage.
|
java.lang.String |
getItem(java.lang.String key)
Take a key and return its value from the local storage if the key exists,
otherwise, return null.
|
java.lang.String |
key(java.lang.Integer n)
Return a key with index n, or null if it is not present.
|
java.lang.Integer |
length()
Return the number of keys stored in the local storage.
|
void |
removeItem(java.lang.String key)
Take a key and remove it from the local storage.
|
void |
setItem(java.lang.String key,
java.lang.String value)
Take a key-value pair and stores the pair into the local storage.
|
public LocalStorageHelper(java.lang.String persistenceDirectory, java.lang.String containerActorName) throws org.eclipse.paho.client.mqttv3.MqttPersistenceException
persistenceDirectory
- The default Mqtt file persistancecontainerActorName
- Container's name plus the actors' display nameorg.eclipse.paho.client.mqttv3.MqttPersistenceException
public java.lang.String getItem(java.lang.String key) throws org.eclipse.paho.client.mqttv3.MqttPersistenceException
key
- The key for the value to be returned.org.eclipse.paho.client.mqttv3.MqttPersistenceException
setItem(String, String)
public void setItem(java.lang.String key, java.lang.String value) throws org.eclipse.paho.client.mqttv3.MqttPersistenceException, java.io.IOException
key
- The key to be stored.value
- The string value associated with the key.org.eclipse.paho.client.mqttv3.MqttPersistenceException
java.io.IOException
getItem(String)
public void removeItem(java.lang.String key) throws org.eclipse.paho.client.mqttv3.MqttPersistenceException
key
- The key to be removed.org.eclipse.paho.client.mqttv3.MqttPersistenceException
public void clear() throws org.eclipse.paho.client.mqttv3.MqttPersistenceException
org.eclipse.paho.client.mqttv3.MqttPersistenceException
public java.lang.String key(java.lang.Integer n) throws org.eclipse.paho.client.mqttv3.MqttException
n
- Index for the key to be returned.org.eclipse.paho.client.mqttv3.MqttException
public java.lang.Integer length() throws org.eclipse.paho.client.mqttv3.MqttPersistenceException
org.eclipse.paho.client.mqttv3.MqttPersistenceException