Package helma.util

Class CacheMap

java.lang.Object
helma.util.CacheMap
All Implemented Interfaces:
ObjectCache
Direct Known Subclasses:
WeakCacheMap

public class CacheMap extends Object implements ObjectCache
  • Constructor Details

    • CacheMap

      public CacheMap()
      Zero argument constructor. Creates a CacheMap with capacity of 1000 and load factor 0.75
    • CacheMap

      public CacheMap(int initialCapacity, float loadFactor)
    • CacheMap

      public CacheMap(int initialCapacity)
  • Method Details

    • size

      public int size()
      Description copied from interface: ObjectCache
      Return the number of objects currently stored in the cache.
      Specified by:
      size in interface ObjectCache
      Returns:
      the number of cached items
    • isEmpty

      public boolean isEmpty()
    • setCapacity

      public void setCapacity(int capacity)
    • containsValue

      public boolean containsValue(Object value)
    • containsKey

      public boolean containsKey(Object key)
      Description copied from interface: ObjectCache
      Returns true if the collection contains an element for the key.
      Specified by:
      containsKey in interface ObjectCache
      Parameters:
      key - the key that we are looking for
    • containsKeys

      public int containsKeys(Object[] keys)
      Description copied from interface: ObjectCache
      Returns the number of keys in object array keys that were not found in the Map. Those keys that are contained in the Map are nulled out in the array.
      Specified by:
      containsKeys in interface ObjectCache
      Parameters:
      keys - an array of key objects we are looking for
      See Also:
    • get

      public Object get(Object key)
      Description copied from interface: ObjectCache
      Gets the object associated with the specified key in the hashtable.
      Specified by:
      get in interface ObjectCache
      Parameters:
      key - the specified key
      Returns:
      the element for the key or null if the key is not defined in the hash table.
      See Also:
    • put

      public Object put(Object key, Object value)
      Description copied from interface: ObjectCache
      Puts the specified element into the hashtable, using the specified key. The element may be retrieved by doing a get() with the same key. The key and the element cannot be null.
      Specified by:
      put in interface ObjectCache
      Parameters:
      key - the specified key in the hashtable
      value - the specified element
      Returns:
      the old value of the key, or null if it did not have one.
      See Also:
    • remove

      public Object remove(Object key)
      Description copied from interface: ObjectCache
      Removes the element corresponding to the key. Does nothing if the key is not present.
      Specified by:
      remove in interface ObjectCache
      Parameters:
      key - the key that needs to be removed
      Returns:
      the value of key, or null if the key was not found.
    • clear

      public boolean clear()
      Description copied from interface: ObjectCache
      Removes all items currently stored in the cache.
      Specified by:
      clear in interface ObjectCache
      Returns:
      true if the operation succeeded
    • shutdown

      public void shutdown()
      Description copied from interface: ObjectCache
      Called when the application holding the cache is stopped.
      Specified by:
      shutdown in interface ObjectCache
    • init

      public void init(Application app)
      Description copied from interface: ObjectCache
      Set the Application instance for the cache.
      Specified by:
      init in interface ObjectCache
      Parameters:
      app - the app instance
    • updateProperties

      public void updateProperties(Properties props)
      Description copied from interface: ObjectCache
      Called when the application's properties have been updated to let the cache implementation update its settings.
      Specified by:
      updateProperties in interface ObjectCache
    • getCachedObjects

      public Object[] getCachedObjects()
      Description copied from interface: ObjectCache
      Return an array with all objects currently contained in the cache.
      Specified by:
      getCachedObjects in interface ObjectCache
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • createTable

      protected Map createTable(int capacity, float loadFactor)
      Override this method to use custom Map implementations. The default implementation returns a java.util.HashMap instance.
      Parameters:
      capacity - the initial capacity
      loadFactor - the load factor
      Returns:
      a new Map used for internal caching
    • getStatistics

      public Map<String,Object> getStatistics()
      Description copied from interface: ObjectCache
      Returns a map of statistics about the cache
      Specified by:
      getStatistics in interface ObjectCache