Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.RuntimeCollective.webapps
Class PermanentCache  view PermanentCache download PermanentCache.java

java.lang.Object
  extended bycom.RuntimeCollective.webapps.PermanentCache
All Implemented Interfaces:
Cache

public class PermanentCache
extends java.lang.Object
implements Cache

The PermanentCache is a Cache which keeps objects forever. They never disappear from the Cache: once you put one in there, it will stay there forever. For this reason, be very careful when using it: a PermanentCache could easily end up eating all the memory. We suggest using it only for limited, set number of objects (eg for a Class which is never instantiated beyond initialization time).

Version:
$Id: PermanentCache.java,v 1.3 2003/09/30 15:13:04 joe Exp $

Field Summary
protected  java.util.HashMap ObjectList
          The internal Hashtable of Objects
 
Constructor Summary
PermanentCache()
           
 
Method Summary
 void clear()
          Empty the whole cache
 java.util.Iterator getIndexedObjects()
          Get all (id, Object) couples return An Iterator of Iterators
 int getNoObjects()
          Get the number of Objects in the cache
 java.lang.Object getObject(int id)
          Get an object for a given key
 java.util.Iterator getObjects()
          Get all Objects return An Iterator of Objects
 void removeObject(int id)
          Remove an object for a given key
 void setObject(int id, java.lang.Object object)
          Set an object for a given key
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ObjectList

protected java.util.HashMap ObjectList
The internal Hashtable of Objects

Constructor Detail

PermanentCache

public PermanentCache()
Method Detail

setObject

public void setObject(int id,
                      java.lang.Object object)
Set an object for a given key

Specified by:
setObject in interface Cache

getObject

public java.lang.Object getObject(int id)
Get an object for a given key

Specified by:
getObject in interface Cache

removeObject

public void removeObject(int id)
Remove an object for a given key

Specified by:
removeObject in interface Cache

getObjects

public java.util.Iterator getObjects()
Get all Objects return An Iterator of Objects

Specified by:
getObjects in interface Cache

getIndexedObjects

public java.util.Iterator getIndexedObjects()
Get all (id, Object) couples return An Iterator of Iterators

Specified by:
getIndexedObjects in interface Cache

getNoObjects

public int getNoObjects()
Get the number of Objects in the cache

Specified by:
getNoObjects in interface Cache

clear

public void clear()
Empty the whole cache

Specified by:
clear in interface Cache