## com.bbn.openmap.layer.vpf
Class VPFFeatureCache

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

public class VPFFeatureCache
extends CacheHandler

The VPFFeatureCache is an extended CacheHandler that caches OMGraphicLists representing a specific feature contained in a CoverageTile. It's used by the VPFCachedFeatureGraphicWarehouse, which in turn is used by the LibraryBean as a central warehouse.

Nested Class Summary
`static class` `VPFFeatureCache.VPFListCacheObject` CacheObject used by VPFFeatureCache.

Field Summary

Fields inherited from class com.bbn.openmap.layer.util.cacheHandler.CacheHandler
`DEFAULT_MAX_CACHE_SIZE, logicalClock, objs`

Constructor Summary
`VPFFeatureCache()` Create a VPFFeatureCache of the default maximum size.
`VPFFeatureCache(int maxSize)` Create a VPFFeatureCache of the specified maximum size.

Method Summary
`protected void` `addToCachedList(OMGraphic omg, java.lang.String featureType, PrimitiveTable pt, java.lang.String type)` Adds an OMGraphic to a list, signified by the feature type and the table.
`static java.lang.String` `createTableCacheKey(java.lang.String featureType, java.lang.String tilePath)` Create an identifying key from the feature type and tile path.
`java.lang.Object` `get(java.lang.String key, java.lang.String featureType)` Additional get method that will call a load() method that takes into account the featureType.
`CacheObject` `load(java.lang.String key)` CacheHandler method to load the new OMGraphicLists (FeatureCacheGraphicLists).
`CacheObject` `load(java.lang.String key, java.lang.String featureType)` CacheHandler method to load the new OMGraphicLists (FeatureCacheGraphicLists).
`boolean` `loadCachedGraphicList(java.lang.String featureType, java.lang.String tilePath, OMGraphicList requestor)` Returns true if the features from a tile (as described by the key) existed and was added to the warehouse graphics list.
`boolean` `needToFetchTileContents(java.lang.String currentFeature, TileDirectory currentTile, OMGraphicList requestor)` Query that the CoverageTable makes to decide whether to read the file contents or to used the cached version.

Methods inherited from class com.bbn.openmap.layer.util.cacheHandler.CacheHandler
`clear, get, getCacheSize, listIterator, replaceLeastUsed, resetCache, resetCache, searchCache`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### VPFFeatureCache

    public VPFFeatureCache()

  Create a VPFFeatureCache of the default maximum size.

### VPFFeatureCache

    public VPFFeatureCache(int maxSize)

  Create a VPFFeatureCache of the specified maximum size.

Method Detail

### addToCachedList

    protected void addToCachedList(OMGraphic omg,
                                   java.lang.String featureType,
                                   PrimitiveTable pt,
                                   java.lang.String type)

  Adds an OMGraphic to a list, signified by the feature type and the table. The PrimitiveTable provides an identifying tile path.

  Parameters:
    `omg` - OMGraphic to add
    `featureType` - the feature code of the OMGraphic
    `pt` - the PrimitiveTable containing the path to the CoverageTile.

### createTableCacheKey

    public static java.lang.String createTableCacheKey(java.lang.String featureType,
                                                       java.lang.String tilePath)

  Create an identifying key from the feature type and tile path.

### loadCachedGraphicList

    public boolean loadCachedGraphicList(java.lang.String featureType,
                                         java.lang.String tilePath,
                                         OMGraphicList requestor)

  Returns true if the features from a tile (as described by the key) existed and was added to the warehouse graphics list. Returns false if the list needs to be created and the contents read in from data files. In both cases the OMGraphicList for the tile/feature is loaded into the cache, the return value is a signal to the caller that the list must be populated or not.

  Parameters:
    `featureType` - the feature type code.
    `tilePath` - the relative path to the tile file.
    `requestor` - the OMGraphicList used to contain cached lists. The cached list will for the featureType/path code will be added to this list, regardless of whether it's been populated or not. The requestor list will be returned when the warehouse is asked for the graphics list.
  Returns:
    true if the list has already been loaded and the caller doesn't need to read the data files to create list contents.

### needToFetchTileContents

    public boolean needToFetchTileContents(java.lang.String currentFeature,
                                           TileDirectory currentTile,
                                           OMGraphicList requestor)

  Query that the CoverageTable makes to decide whether to read the file contents or to used the cached version.

  Parameters:
    `currentFeature` - the feature type
    `currentTile` - the tile directory
    `requestor` - the OMGraphicList to add the cached list to. If the CoverageTable reads the data files, the OMGraphics created from the files will be added to the list added to the requestor.
  Returns:
    true if the CoverageTable needs to read the data files.

### get

    public java.lang.Object get(java.lang.String key,
                                java.lang.String featureType)

  Additional get method that will call a load() method that takes into account the featureType. The regular get() method will not be used, unless something else calls it, which is not advised.

  Parameters:
    `key` - the created key for cached list, see createTableCacheKey
    `featureType` - the kind of feature, VPFUtil.Area, VPFUtil.Edge, VPFUtil.Point or VPFUtil.Text.

### load

    public CacheObject load(java.lang.String key)

  CacheHandler method to load the new OMGraphicLists (FeatureCacheGraphicLists). Shouldn't be used because the FeatureCacheGraphicList type will be unknown. This method is only defined to implement the CacheHandler abstract method.

  Specified by:
    `load` in class `CacheHandler`

### load

    public CacheObject load(java.lang.String key,
                            java.lang.String featureType)

  CacheHandler method to load the new OMGraphicLists (FeatureCacheGraphicLists).

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