com.bbn.openmap.util.cacheHandler
Class CacheHandler

java.lang.Object
  extended by com.bbn.openmap.util.cacheHandler.CacheHandler
Direct Known Subclasses:
ASRPDirectory, DTEDFrameCache, DTEDFrameCache, DTEDFrameCacheHandler, ImageTile.Cache, RpfFrameCacheHandler, StandardMapTileFactory, VPFFeatureCache

public abstract class CacheHandler
extends java.lang.Object

A base cache support object. Based on the com.bbn.openmap.layer.util.cacheHandler package components, this CacheHandler uses Objects instead of Strings and will be replacing the earlier version.

Author:
dietrick

Field Summary
static int DEFAULT_MAX_CACHE_SIZE
           
static java.util.logging.Logger logger
           
protected  int logicalClock
           
protected  CacheObject[] objs
           
 
Constructor Summary
CacheHandler()
          Standard default constructor
CacheHandler(int max_size)
          Constructor used when you know the limits
 
Method Summary
 void clear()
          Remove all the objects from the cache.
 java.lang.Object get(java.lang.Object key)
          The main call to retrieve something from the cache
 int getCacheSize()
          Get the current size of the cache.
 java.util.ListIterator<CacheObject> listIterator()
          Return a ListIterator of the cache objects.
abstract  CacheObject load(java.lang.Object key)
          Called from get if the key doesn't exist, to "load" the new object into the cache before returning it.
protected  void replaceLeastUsed(CacheObject newObj)
          If there is space in the cache, put the object in.
 void resetCache()
          Need to clear memory, get gc moving, and ready for new objects
 void resetCache(int max_size)
          Need to clear memory, get gc moving, and ready for new objects.
 CacheObject searchCache(java.lang.Object key)
          Search the cache for a match -return null if not found.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

objs

protected CacheObject[] objs

logicalClock

protected int logicalClock

logger

public static java.util.logging.Logger logger

DEFAULT_MAX_CACHE_SIZE

public static int DEFAULT_MAX_CACHE_SIZE
Constructor Detail

CacheHandler

public CacheHandler()
Standard default constructor


CacheHandler

public CacheHandler(int max_size)
Constructor used when you know the limits

Method Detail

clear

public void clear()
Remove all the objects from the cache.


resetCache

public void resetCache()
Need to clear memory, get gc moving, and ready for new objects


resetCache

public void resetCache(int max_size)
Need to clear memory, get gc moving, and ready for new objects. Delete the current Hashtable and create a new one with the new capacity.

Parameters:
max_size - the capacity of the Hashtable.

getCacheSize

public int getCacheSize()
Get the current size of the cache.


get

public java.lang.Object get(java.lang.Object key)
The main call to retrieve something from the cache


load

public abstract CacheObject load(java.lang.Object key)
Called from get if the key doesn't exist, to "load" the new object into the cache before returning it. This function should define how a CacheObject is created, or loaded from the file system, or whatever.


searchCache

public CacheObject searchCache(java.lang.Object key)
Search the cache for a match -return null if not found. The key search is case insensitive.


replaceLeastUsed

protected void replaceLeastUsed(CacheObject newObj)
If there is space in the cache, put the object in. If there isn't space, find the least used object, and replace it.


listIterator

public java.util.ListIterator<CacheObject> listIterator()
Return a ListIterator of the cache objects.



Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details