public class ReferenceObjectCache extends Object implements ObjectCache
WeakReference or SoftReference to them. Java Garbage
 Collection can then free these objects if no one has a "strong" reference to the object (weak) or if it runs out of
 memory (soft).| Constructor and Description | 
|---|
| ReferenceObjectCache(boolean useWeak) | 
| Modifier and Type | Method and Description | 
|---|---|
| <T> void | cleanNullReferences(Class<T> clazz)Run through the map and remove any references that have been null'd out by the GC. | 
| <T> void | cleanNullReferencesAll()Run through all maps and remove any references that have been null'd out by the GC. | 
| <T> void | clear(Class<T> clazz)Remove all entries from the cache of a certain class. | 
| void | clearAll()Remove all entries from the cache of all classes. | 
| <T,ID> T | get(Class<T> clazz,
   ID id)Lookup in the cache for an object of a certain class that has a certain id. | 
| static ReferenceObjectCache | makeSoftCache()Create and return an object cache using  SoftReference. | 
| static ReferenceObjectCache | makeWeakCache()Create and return an object cache using  WeakReference. | 
| <T,ID> void | put(Class<T> clazz,
   ID id,
   T data)Put an object in the cache that has a certain class and id. | 
| <T> void | registerClass(Class<T> clazz)Register a class for use with this class. | 
| <T,ID> void | remove(Class<T> clazz,
      ID id)Delete from the cache an object of a certain class that has a certain id. | 
| <T> int | size(Class<T> clazz)Return the number of elements in the cache. | 
| int | sizeAll()Return the number of elements in all of the caches. | 
| <T,ID> T | updateId(Class<T> clazz,
        ID oldId,
        ID newId)Change the id in the cache for an object of a certain class from an old-id to a new-id. | 
public ReferenceObjectCache(boolean useWeak)
useWeak - Set to true if you want the cache to use WeakReference. If false then the cache will use
            SoftReference.public static ReferenceObjectCache makeWeakCache()
WeakReference.public static ReferenceObjectCache makeSoftCache()
SoftReference.public <T> void registerClass(Class<T> clazz)
ObjectCacheregisterClass in interface ObjectCachepublic <T,ID> T get(Class<T> clazz, ID id)
ObjectCacheget in interface ObjectCachepublic <T,ID> void put(Class<T> clazz, ID id, T data)
ObjectCacheput in interface ObjectCachepublic <T> void clear(Class<T> clazz)
ObjectCacheclear in interface ObjectCachepublic void clearAll()
ObjectCacheclearAll in interface ObjectCachepublic <T,ID> void remove(Class<T> clazz, ID id)
ObjectCacheremove in interface ObjectCachepublic <T,ID> T updateId(Class<T> clazz, ID oldId, ID newId)
ObjectCacheupdateId in interface ObjectCachepublic <T> int size(Class<T> clazz)
ObjectCachesize in interface ObjectCachepublic int sizeAll()
ObjectCachesizeAll in interface ObjectCachepublic <T> void cleanNullReferences(Class<T> clazz)
public <T> void cleanNullReferencesAll()
This documentation is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.