public class BasicCacheVisitor extends Object implements DiskMemTileCacheVisitor
DiskMemTileCache that can be used
to examine cache contents.
Example of use:
// Query the cache for tiles that belong to a given image
// and that are currently resident in memory
DiskMemTileCache cache = ...
RenderedImage owner = ...
Map filters = CollectionFactory.newMap();
filters.put(BasicCacheVisitor.Key.OWNER, owner);
filters.put(BasicCachevisitor.Key.RESIDENT, Boolean.TRUE);
BasicCacheVisitor visitor = new BasicCacheVisitor();
visitor.setFilters(filters);
cache.accept(visitor);
for (DiskCachedTile tile : visitor.getTiles()) {
System.out.println(String.format("tile %d,%d", tile.getTileX(), tile.getTileY()));
}
| Modifier and Type | Class and Description |
|---|---|
static class |
BasicCacheVisitor.Key
Defines keys to filter the tles visited
|
| Constructor and Description |
|---|
BasicCacheVisitor() |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clear collected tile data.
|
void |
clearFilters()
Clear all existing filter conditions
|
Collection<DiskCachedTile> |
getTiles()
Returns an unmodifiable collection of tiles retrieved from
the cache.
|
void |
setFilter(BasicCacheVisitor.Key key,
Object value)
Set a single filter condition.
|
void |
setFilters(Map<BasicCacheVisitor.Key,Object> params)
Set filter conditions.
|
void |
visit(DiskCachedTile tile,
boolean isResident)
This method is called by the cache for each tile in turn.
|
public void setFilters(Map<BasicCacheVisitor.Key,Object> params)
params - a Map where each key is one of the constants
defined by BasicCacheVisitor.Key and each value is the
corresponding value to match tiles againstpublic void setFilter(BasicCacheVisitor.Key key, Object value)
key - one of the constants defined by BasicCacheVisitor.Keyvalue - corresponding value to match tiles againstpublic void clearFilters()
public Collection<DiskCachedTile> getTiles()
public void visit(DiskCachedTile tile, boolean isResident)
visit in interface DiskMemTileCacheVisitortile - the cached tile being visitedisResident - set by the cache to indicate whether the tile is
currently resident in memorypublic void clear()
Copyright © 2009–2018. All rights reserved.