net.sourceforge.wurfl.core.cache
Class HashMapCacheProvider

java.lang.Object
  extended by net.sourceforge.wurfl.core.cache.HashMapCacheProvider
All Implemented Interfaces:
CacheProvider

public class HashMapCacheProvider
extends Object
implements CacheProvider

CacheProvider HashMap implementation.

Version:
$Id: HashMapCacheProvider.java 934 2012-03-27 13:34:26Z fulvio.crivellaro $

Constructor Summary
HashMapCacheProvider()
          Default constructor
HashMapCacheProvider(int initialCapacity)
          Constructor by the initial capacity.
HashMapCacheProvider(int initialCapacity, float loadFactor)
          Constructor by the initial capacity and load factor.
HashMapCacheProvider(int initialCapacity, float loadFactor, int concurrentWrites)
          Constructor by the initial capacity, loadFactor and maximum concurrent writes
 
Method Summary
 void clear()
          Remove all items from cache.
 int getConcurrentWrites()
          Return the maximum threads can write the cache.
 Device getDevice(String key)
          Returns the cached item.
 Device getDeviceFromDeviceId(String deviceId)
          Returns the cached device, from the deviceId.
 int getInitialCapacity()
          Return the initial capacity of the hashMap.
 float getLoadFactor()
          Return the hashMap load factor.
 void putDevice(String key, Device target)
          Put an item in cache associated to a key.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HashMapCacheProvider

public HashMapCacheProvider()
Default constructor


HashMapCacheProvider

public HashMapCacheProvider(int initialCapacity)
Constructor by the initial capacity.

Parameters:
initialCapacity -

HashMapCacheProvider

public HashMapCacheProvider(int initialCapacity,
                            float loadFactor)
Constructor by the initial capacity and load factor.

Parameters:
initialCapacity - The hashMap initial capacity.
loadFactor - The hashMap load factor.

HashMapCacheProvider

public HashMapCacheProvider(int initialCapacity,
                            float loadFactor,
                            int concurrentWrites)
Constructor by the initial capacity, loadFactor and maximum concurrent writes

Parameters:
initialCapacity - The hashMap initial capacity.
loadFactor - The hashMap load factor.
concurrentWrites - The maximum thread can write the cache.
Method Detail

getInitialCapacity

public int getInitialCapacity()
Return the initial capacity of the hashMap.

Returns:
the initial capacity of the hashMap.

getLoadFactor

public float getLoadFactor()
Return the hashMap load factor.

Returns:
the hashMap load factor.

getConcurrentWrites

public int getConcurrentWrites()
Return the maximum threads can write the cache.

Returns:
a int representing the maximum thread can write the cache.

clear

public void clear()
Remove all items from cache.

Specified by:
clear in interface CacheProvider

getDevice

public Device getDevice(String key)
Returns the cached item.

Specified by:
getDevice in interface CacheProvider
Parameters:
key - The cached item key.
Returns:
Cached Object, null if this cache does not contain it.

putDevice

public void putDevice(String key,
                      Device target)
Put an item in cache associated to a key.

Specified by:
putDevice in interface CacheProvider
Parameters:
key - The caching item key.
target - The caching item.

toString

public String toString()
Overrides:
toString in class Object

getDeviceFromDeviceId

public Device getDeviceFromDeviceId(String deviceId)
Description copied from interface: CacheProvider
Returns the cached device, from the deviceId.

Specified by:
getDeviceFromDeviceId in interface CacheProvider
Returns:
Cached Device, null if this cache does not contain it.


Copyright © 2012 ScientiaMobile Inc.. All Rights Reserved.