public class Cache extends Object implements CacheReporter
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
autoUpdate
Whether the cache should automatically update when a parameter changes.
|
protected Object[] |
cache
Master array containing cached objects.
|
protected int[] |
currentPos
Current dimensional position.
|
protected boolean[] |
inCache
Whether each position is currently supposed to be cached.
|
protected Vector<CacheListener> |
listeners
List of cache event listeners.
|
protected ICacheSource |
source
Current cache source.
|
protected ICacheStrategy |
strategy
Current cache strategy.
|
| Constructor and Description |
|---|
Cache(ICacheStrategy strategy,
ICacheSource source,
boolean autoUpdate)
Constructs an object cache with the given cache strategy and source.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCacheListener(CacheListener l)
Adds a listener for status update events.
|
CacheListener[] |
getCacheListeners()
Gets a list of all registered status update listeners.
|
int[] |
getCurrentPos()
Gets the current dimensional position.
|
Object |
getObject(int[] pos)
Gets the cached object at the given dimensional position.
|
ICacheSource |
getSource()
Gets the cache's caching source.
|
ICacheStrategy |
getStrategy()
Gets the cache's caching strategy.
|
boolean |
isInCache(int pos)
Returns true if the object at the given index is in the cache.
|
boolean |
isInCache(int[] pos)
Returns true if the object at the given dimensional position is
in the cache.
|
protected void |
notifyListeners(CacheEvent e)
Informs listeners of a cache update.
|
void |
recache()
Updates all planes on the load list.
|
void |
recache(int n)
Updates the given plane.
|
void |
removeCacheListener(CacheListener l)
Removes a listener for status update events.
|
void |
reset()
Reallocates the cache.
|
void |
setCurrentPos(int[] pos)
Sets the current dimensional position.
|
void |
setSource(ICacheSource source)
Sets the cache's caching source.
|
void |
setStrategy(ICacheStrategy strategy)
Sets the cache's caching strategy.
|
protected ICacheStrategy strategy
protected ICacheSource source
protected int[] currentPos
protected Object[] cache
protected boolean[] inCache
protected Vector<CacheListener> listeners
protected boolean autoUpdate
public Cache(ICacheStrategy strategy, ICacheSource source, boolean autoUpdate) throws CacheException
CacheExceptionpublic Object getObject(int[] pos) throws CacheException
CacheExceptionpublic boolean isInCache(int[] pos)
throws CacheException
CacheExceptionpublic boolean isInCache(int pos)
throws CacheException
CacheExceptionpublic void reset()
throws CacheException
CacheExceptionpublic ICacheStrategy getStrategy()
public ICacheSource getSource()
public int[] getCurrentPos()
public void setStrategy(ICacheStrategy strategy) throws CacheException
CacheExceptionpublic void setSource(ICacheSource source) throws CacheException
CacheExceptionpublic void setCurrentPos(int[] pos)
throws CacheException
CacheExceptionpublic void recache(int n)
throws CacheException
CacheExceptionpublic void recache()
throws CacheException
CacheExceptionpublic void addCacheListener(CacheListener l)
CacheReporteraddCacheListener in interface CacheReporterpublic void removeCacheListener(CacheListener l)
CacheReporterremoveCacheListener in interface CacheReporterpublic CacheListener[] getCacheListeners()
CacheReportergetCacheListeners in interface CacheReporterprotected void notifyListeners(CacheEvent e)
Copyright © 2015 Open Microscopy Environment