org.opensaml.util.storage
Class MapBasedStorageService<KeyType,ValueType>

java.lang.Object
  extended by org.opensaml.util.storage.MapBasedStorageService<KeyType,ValueType>
Type Parameters:
KeyType - object type of the keys
ValueType - object type of the values
All Implemented Interfaces:
StorageService<KeyType,ValueType>

public class MapBasedStorageService<KeyType,ValueType>
extends java.lang.Object
implements StorageService<KeyType,ValueType>

A simple Map based StorageService implementation.


Constructor Summary
MapBasedStorageService()
          Constructor.
 
Method Summary
 boolean contains(KeyType key)
          Checks if a given key exists.
 ValueType get(KeyType key)
          Gets the value stored under a particular key.
 java.util.Collection<KeyType> getKeys()
          Gets the keys for entries in the storage service.
 ValueType put(KeyType key, ValueType value)
          Adds a value, indexed by a key, in to storage.
 ValueType remove(KeyType key)
          Removes an item from storage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapBasedStorageService

public MapBasedStorageService()
Constructor.

Method Detail

getKeys

public java.util.Collection<KeyType> getKeys()
Gets the keys for entries in the storage service. Note: this operation may be very expensive

Specified by:
getKeys in interface StorageService<KeyType,ValueType>
Returns:
list of keys currently within the store

contains

public boolean contains(KeyType key)
Checks if a given key exists.

Specified by:
contains in interface StorageService<KeyType,ValueType>
Parameters:
key - the key to check
Returns:
true of the given key exists, false if not

get

public ValueType get(KeyType key)
Gets the value stored under a particular key.

Specified by:
get in interface StorageService<KeyType,ValueType>
Parameters:
key - the key
Returns:
the value for that key, or null if there is no value for the given key

put

public ValueType put(KeyType key,
                     ValueType value)
Adds a value, indexed by a key, in to storage. Note that implementations of this service may determine, on its own, when to evict items from storage, the expiration time given here is meant only as a system provided hint.

Specified by:
put in interface StorageService<KeyType,ValueType>
Parameters:
key - the key
value - the value
Returns:
the value that was registered under that key previously, if there was a previous value

remove

public ValueType remove(KeyType key)
Removes an item from storage.

Specified by:
remove in interface StorageService<KeyType,ValueType>
Parameters:
key - the key to the value to remove
Returns:
the value that was removed