## com.bbn.openmap.layer.util.cacheHandler
Class CacheHandler

    java.lang.Object
      com.bbn.openmap.layer.util.cacheHandler.CacheHandler

Direct Known Subclasses:
  ASRPDirectory, DTEDFrameCache, DTEDFrameCache, DTEDFrameCacheHandler, RpfFrameCacheHandler, VPFFeatureCache

public abstract class CacheHandler
extends java.lang.Object

Field Summary
`static int` `DEFAULT_MAX_CACHE_SIZE`
`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.String key)` The main call to retrieve something from the cache
`int` `getCacheSize()` Get the current size of the cache.
`java.util.ListIterator` `listIterator()` Return a ListIterator of the cache objects.
`abstract CacheObject` `load(java.lang.String 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.String 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

### 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.String key)

  The main call to retrieve something from the cache

### load

    public abstract CacheObject load(java.lang.String 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.String 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 listIterator()

  Return a ListIterator of the cache objects.

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