com.j_spaces.map
Class GSMapImpl

java.lang.Object
  extended by com.j_spaces.map.AbstractMap
      extended by com.j_spaces.map.GSMapImpl
All Implemented Interfaces:
Cache, IMap, Map

public final class GSMapImpl
extends com.j_spaces.map.AbstractMap

This class provides an implementation to GigaSpaces IMap interface, for Distributed Caching using Map API. Simply call Map.get and Map.put methods to store and retrieve values into or from the cache.

For more detailed information about GSMapImpl class usage see: Cache API


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
 
Fields inherited from class com.j_spaces.map.AbstractMap
NONE_COMPRESSION, ZIP_COMPRESSION
 
Constructor Summary
GSMapImpl(IJSpace space)
          GSMap constructor.
GSMapImpl(IJSpace space, int compress)
          GSMap constructor.
GSMapImpl(IJSpace space, long timeToLive)
          GSMap constructor.
GSMapImpl(IJSpace space, Transaction txn)
          GSMap constructor.
 
Method Summary
 void addListener(CacheListener listener)
          Unsupported Operation!
 void clear()
          The clear method will remove all objects from the cache including the key and the associated value.
 void clear(boolean clearMaster)
          The clear method will remove all objects from the cache including the key and the associated value.
 boolean containsKey(Object key)
          Returns true if the cache contains the specified key.
 boolean containsValue(Object value)
          Returns true if this cache maps one or more keys to the specified value.
 Set entrySet()
          Returns a set view of the objects currently contained in the cache.
 boolean evict(Object key)
          The evict method will remove object from the cache the matches the provided key.
 CacheEntry getCacheEntry(Object key)
          Returns the CacheEntry object associated with the object identified by "key".
 Set keySet()
          Returns a set view of the keys currently contained in the cache.
 Object peek(Object key)
          The peek method will return the object associated with "key" if it currently exists (and is valid) in the cache.
 void removeListener(CacheListener listener)
          Unsupported Operation!
 Collection values()
          Returns a collection view of the values contained in this cache.
 
Methods inherited from class com.j_spaces.map.AbstractMap
get, get, get, getAll, getLocalSpace, getMasterSpace, getTimeToLive, getTransaction, getWaitForResponse, isEmpty, isVersioned, load, loadAll, put, put, put, putAll, putAll, remove, remove, remove, setTimeToLive, setTransaction, setVersioned, setWaitForResponse, size
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.j_spaces.javax.cache.Cache
equals, hashCode
 

Constructor Detail

GSMapImpl

public GSMapImpl(IJSpace space)
GSMap constructor.

Parameters:
space - Space proxy or DCache proxy.

GSMapImpl

public GSMapImpl(IJSpace space,
                 long timeToLive)
GSMap constructor.

Parameters:
space - Space proxy or DCache proxy.
timeToLive - Time to live for value object in cache.

GSMapImpl

public GSMapImpl(IJSpace space,
                 int compress)
GSMap constructor.

Parameters:
space - Space proxy or DCache proxy.
compress - Compress value object in cache.

GSMapImpl

public GSMapImpl(IJSpace space,
                 Transaction txn)
GSMap constructor.

Parameters:
space - Space proxy or DCache proxy.
txn - if not null all operation will be executed with the desired transaction. To set new transaction use: setTransaction(txn) To reset the transaction use: setTransaction(null) To get the current transaction use: getTransaction()
Method Detail

containsKey

public boolean containsKey(Object key)
Returns true if the cache contains the specified key. The search is scoped to the cache. Other caches in the system will not be searched and a CacheLoader will not be called.

Parameters:
key - key whose presence in this cache is to be tested.
Returns:
true, if the cache contains the specified key.

containsValue

public boolean containsValue(Object value)
Returns true if this cache maps one or more keys to the specified value. The search is scoped to the cache. Other caches in the system will not be searched and a CacheLoader will not be called.

Parameters:
value - value whose presence in this cache is to be tested.
Returns:
true, if the cache contains the specified value.

clear

public void clear()
The clear method will remove all objects from the cache including the key and the associated value.


clear

public void clear(boolean clearMaster)
The clear method will remove all objects from the cache including the key and the associated value.

Parameters:
clearMaster - if true clear also master, when false equals to clear()

values

public Collection values()
Returns a collection view of the values contained in this cache. The search is scoped to the cache. Other caches in the system will not be searched and a CacheLoader will not be called.

Returns:
a collection view of the values contained in this cache.

entrySet

public Set entrySet()
Returns a set view of the objects currently contained in the cache. The search is scoped to the cache. Other caches in the system will not be searched and a CacheLoader will not be called.

Returns:
a set of CacheEntry

keySet

public Set keySet()
Returns a set view of the keys currently contained in the cache. The search is scoped to the cache. Other caches in the system will not be searched and a CacheLoader will not be called.

Returns:
set of the keys

addListener

public final void addListener(CacheListener listener)
Unsupported Operation! Add a listener to the list of cache listeners.
Optional, not supported by all the implementations, currently supported only by local cache.

Parameters:
listener - call back CacheListener

evict

public final boolean evict(Object key)
The evict method will remove object from the cache the matches the provided key.

Parameters:
key - the key to evict
Returns:
true, if the key was evicted

getCacheEntry

public final CacheEntry getCacheEntry(Object key)
Returns the CacheEntry object associated with the object identified by "key".

Parameters:
key - key whose associated value is to be returned.
Returns:
the CacheEntry to which this cache maps the specified key, or null if the cache contains no mapping for this key.

peek

public Object peek(Object key)
The peek method will return the object associated with "key" if it currently exists (and is valid) in the cache. The search is scoped to the cache. Other caches in the system will not be searched and a CacheLoader will not be called.

Parameters:
key - key whose associated value is to be peek.
Returns:
the value to which this cache maps the specified key, or null if the cache contains no mapping for this key.

removeListener

public void removeListener(CacheListener listener)
Unsupported Operation! Remove a listener from the list of cache listeners.
Optional, not supported by all the implementations, currently supported only by local cache

Parameters:
listener - the CacheListener to remove