com.funambol.storage
Interface StringKeyValueStore

All Known Implementing Classes:
StringKeyValueFileStore, StringKeyValueMemoryStore

public interface StringKeyValueStore

This interface defines a generic data store for strings where data is orgnized as key/value pair. The store is persistable and each implementation is free to choose where and how data is persisted. Note that the lack of serializable concept in jme prevents this store to be more generic. The Funambol APIs have the notion of Serializable but that interface is not implemented by String, so it would be coumbersome to have a simple KeyValueStore for strings.


Method Summary
 void add(java.lang.String key, java.lang.String value)
          Add a new item into the store.
 boolean contains(java.lang.String key)
          Returns true iff key is contained in this store.
 java.lang.String get(java.lang.String key)
          Returns the value associated to the given key or null if not present.
 java.util.Enumeration keys()
          Returns an enumeration with all the keys in the store.
 java.util.Enumeration keyValuePairs()
          Returns an enumeration of all the key/value pairs in the store.
 void load()
          Load this store into memory.
 java.lang.String put(java.lang.String key, java.lang.String value)
          Deprecated. Use add and update methods instead.
 java.lang.String remove(java.lang.String key)
          Removes an entry from the store
 void reset()
          Resets this data store.
 void save()
          Persist this store.
 void update(java.lang.String key, java.lang.String value)
          Update and existing item into the store.
 

Method Detail

add

void add(java.lang.String key,
         java.lang.String value)
Add a new item into the store. The item is not persisted but it is cached. Clients should invoke the save method to persist changes.

Parameters:
key - the unique key for this item (cannot be null)
value - the value to be stored

update

void update(java.lang.String key,
            java.lang.String value)
Update and existing item into the store. The item is not persisted but it is cached. Clients should invoke the save method to persist changes.

Parameters:
key - the unique key of the existing item
value - the value to be stored

put

java.lang.String put(java.lang.String key,
                     java.lang.String value)
                     throws java.lang.Exception
Deprecated. Use add and update methods instead.

Add a new item into the store. The item is not persisted but it is cached. Clients should invoke the save method to persist changes. If an element with the same key exists, then it is replaced.

Parameters:
key - the unique key for this item (cannot be null)
value - the value to be stored
Returns:
the old value associated to this key (null if it was not present)
Throws:
java.lang.Exception - if the operation can't be performed

get

java.lang.String get(java.lang.String key)
Returns the value associated to the given key or null if not present.

Parameters:
key - is the key (cannot be null)
Returns:
the value in the store or null if not present

keys

java.util.Enumeration keys()
Returns an enumeration with all the keys in the store. The elements type is String.

Returns:
the keys

keyValuePairs

java.util.Enumeration keyValuePairs()
Returns an enumeration of all the key/value pairs in the store. The elements type is KeyValuePair.

Returns:
the key/value pairs

contains

boolean contains(java.lang.String key)
Returns true iff key is contained in this store.


remove

java.lang.String remove(java.lang.String key)
Removes an entry from the store

Parameters:
key - the item key
Returns:
the value associated to the item being deleted or null if the item is not in the store

save

void save()
          throws java.io.IOException
Persist this store.

Throws:
java.io.IOException - if the operation cannot be performed

load

void load()
          throws java.io.IOException
Load this store into memory.

Throws:
java.io.IOException - if the operation cannot be performed

reset

void reset()
           throws java.io.IOException
Resets this data store. All data is lost after this call.

Throws:
java.io.IOException - if the operation fails


Copyright © 2001-2009 Funambol.