com.funambol.storage
Class StringKeyValueMemoryStore

java.lang.Object
  extended by com.funambol.storage.StringKeyValueMemoryStore
All Implemented Interfaces:
StringKeyValueStore

public class StringKeyValueMemoryStore
extends java.lang.Object
implements StringKeyValueStore


Field Summary
protected  java.util.Hashtable store
           
 
Constructor Summary
StringKeyValueMemoryStore()
           
 
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)
          Add a new item into the store.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

store

protected java.util.Hashtable store
Constructor Detail

StringKeyValueMemoryStore

public StringKeyValueMemoryStore()
Method Detail

add

public void add(java.lang.String key,
                java.lang.String value)
Description copied from interface: StringKeyValueStore
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.

Specified by:
add in interface StringKeyValueStore
Parameters:
key - the unique key for this item (cannot be null)
value - the value to be stored

update

public void update(java.lang.String key,
                   java.lang.String value)
Description copied from interface: StringKeyValueStore
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.

Specified by:
update in interface StringKeyValueStore
Parameters:
key - the unique key of the existing item
value - the value to be stored

put

public java.lang.String put(java.lang.String key,
                            java.lang.String value)
Description copied from interface: StringKeyValueStore
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.

Specified by:
put in interface StringKeyValueStore
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)

get

public java.lang.String get(java.lang.String key)
Description copied from interface: StringKeyValueStore
Returns the value associated to the given key or null if not present.

Specified by:
get in interface StringKeyValueStore
Parameters:
key - is the key (cannot be null)
Returns:
the value in the store or null if not present

keys

public java.util.Enumeration keys()
Description copied from interface: StringKeyValueStore
Returns an enumeration with all the keys in the store. The elements type is String.

Specified by:
keys in interface StringKeyValueStore
Returns:
the keys

keyValuePairs

public java.util.Enumeration keyValuePairs()
Description copied from interface: StringKeyValueStore
Returns an enumeration of all the key/value pairs in the store. The elements type is KeyValuePair.

Specified by:
keyValuePairs in interface StringKeyValueStore
Returns:
the key/value pairs

contains

public boolean contains(java.lang.String key)
Description copied from interface: StringKeyValueStore
Returns true iff key is contained in this store.

Specified by:
contains in interface StringKeyValueStore

remove

public java.lang.String remove(java.lang.String key)
Description copied from interface: StringKeyValueStore
Removes an entry from the store

Specified by:
remove in interface StringKeyValueStore
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

public void save()
          throws java.io.IOException
Description copied from interface: StringKeyValueStore
Persist this store.

Specified by:
save in interface StringKeyValueStore
Throws:
java.io.IOException - if the operation cannot be performed

load

public void load()
          throws java.io.IOException
Description copied from interface: StringKeyValueStore
Load this store into memory.

Specified by:
load in interface StringKeyValueStore
Throws:
java.io.IOException - if the operation cannot be performed

reset

public void reset()
           throws java.io.IOException
Description copied from interface: StringKeyValueStore
Resets this data store. All data is lost after this call.

Specified by:
reset in interface StringKeyValueStore
Throws:
java.io.IOException - if the operation fails


Copyright © 2001-2009 Funambol.