org.sdnplatform.sync.internal.store
Interface IStore<K,V>

All Known Subinterfaces:
IStorageEngine<K,V>
All Known Implementing Classes:
InMemoryStorageEngine, JacksonStore, JavaDBStorageEngine, ListenerStorageEngine, RemoteStore, SynchronizingStorageEngine

public interface IStore<K,V>

The basic interface used for storage and storage decorators. Allows the usual crud operations. Note that certain operations rely on the correct implementation of equals and hashCode for the key. As such, arrays as keys should be avoided.


Method Summary
 void close()
          Close the store.
 IClosableIterator<java.util.Map.Entry<K,java.util.List<Versioned<V>>>> entries()
          Get an iterator over pairs of entries in the store.
 java.util.List<Versioned<V>> get(K key)
          Get the value associated with the given key
 java.lang.String getName()
           
 java.util.List<IVersion> getVersions(K key)
          Get a list of the versions associated with the given key
 void put(K key, Versioned<V> value)
          Associate the value with the key and version in this store
 

Method Detail

get

java.util.List<Versioned<V>> get(K key)
                                 throws SyncException
Get the value associated with the given key

Parameters:
key - The key to check for
Returns:
The value associated with the key or an empty list if no values are found.
Throws:
SyncException

entries

IClosableIterator<java.util.Map.Entry<K,java.util.List<Versioned<V>>>> entries()
Get an iterator over pairs of entries in the store. The key is the first element in the pair and the versioned value is the second element. Note that the iterator need not be threadsafe, and that it must be manually closed after use.

Returns:
An iterator over the entries in this StorageEngine.

put

void put(K key,
         Versioned<V> value)
         throws SyncException
Associate the value with the key and version in this store

Parameters:
key - The key to use
value - The value to store and its version.
Throws:
SyncException

getVersions

java.util.List<IVersion> getVersions(K key)
                                     throws SyncException
Get a list of the versions associated with the given key

Parameters:
key - the key
Returns:
the list of IVersion objects
Throws:
SyncException

getName

java.lang.String getName()
Returns:
The name of the store.

close

void close()
           throws SyncException
Close the store.

Throws:
SyncException - If closing fails.