|
NASA World Wind | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgov.nasa.worldwind.cache.BasicMemoryCache
public final class BasicMemoryCache
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface gov.nasa.worldwind.cache.MemoryCache |
---|
MemoryCache.CacheListener |
Constructor Summary | |
---|---|
BasicMemoryCache(long loWater,
long capacity)
Constructs a new cache using capacity for maximum size, and loWater for the low water. |
Method Summary | |
---|---|
boolean |
add(java.lang.Object key,
Cacheable clientObject)
Attempts to add the Cacheable object referenced by the key. |
boolean |
add(java.lang.Object key,
java.lang.Object clientObject,
long clientObjectSize)
Adds an object to the cache. |
void |
addCacheListener(MemoryCache.CacheListener listener)
Adds a cache listener, MemoryCache listeners are used to notify classes when an item is removed from the cache. |
void |
clear()
Empties the cache. |
boolean |
contains(java.lang.Object key)
Returns true if the cache contains the item referenced by key. |
protected void |
finalize()
|
long |
getCapacity()
Retrieves the maximum size of the cache in bytes. |
long |
getFreeCapacity()
Retrieves the available space for storing new items. |
java.util.Set<java.lang.Object> |
getKeySet()
Obtain a list of all the keys in the cache. |
long |
getLowWater()
Returns the low water level in bytes. |
java.lang.String |
getName()
|
int |
getNumObjects()
Retrieve the number of items stored in the MemoryCache . |
java.lang.Object |
getObject(java.lang.Object key)
Obtain the object referenced by key without removing it. |
long |
getUsedCapacity()
Retrieves the amount of used MemoryCache space. |
void |
remove(java.lang.Object key)
Remove the object reference by key from the cache. |
void |
removeCacheListener(MemoryCache.CacheListener listener)
Removes a cache listener, objects using this listener will no longer receive notification of cache events. |
void |
setCapacity(long newCapacity)
Sets the new capacity (in bytes) for the cache. |
void |
setLowWater(long loWater)
Sets the new low water level in bytes, which controls how aggresively the cache discards items. |
void |
setName(java.lang.String name)
|
java.lang.String |
toString()
a String representation of this object is returned. This representation consists of maximum
size, current used capacity and number of currently cached items. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public BasicMemoryCache(long loWater, long capacity)
capacity
for maximum size, and loWater
for the low water.
loWater
- the low water levelcapacity
- the maximum capacityMethod Detail |
---|
public boolean add(java.lang.Object key, Cacheable clientObject)
MemoryCache
Cacheable
object referenced by the key. No explicit size value is required as
this method queries the Cacheable to discover the size.
This method should be declared synchronized
when it is implemented.
add
in interface MemoryCache
Cacheable
public boolean add(java.lang.Object key, java.lang.Object clientObject, long clientObjectSize)
add
in interface MemoryCache
key
- The unique reference key that identifies this object.clientObject
- The actual object to be cached.clientObjectSize
- The size of the object in bytes.
public void addCacheListener(MemoryCache.CacheListener listener)
addCacheListener
in interface MemoryCache
listener
- The new CacheListener
java.lang.IllegalArgumentException
- is listener
is nullpublic void clear()
clear
in interface MemoryCache
public boolean contains(java.lang.Object key)
getObject()
should be used for that purpose
contains
in interface MemoryCache
key
- The key of a specific object
java.lang.IllegalArgumentException
- if key
is nullprotected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public long getCapacity()
MemoryCache
getCapacity
in interface MemoryCache
public long getFreeCapacity()
MemoryCache
getFreeCapacity
in interface MemoryCache
public java.util.Set<java.lang.Object> getKeySet()
getKeySet
in interface MemoryCache
Set
of all keys in the cache.public long getLowWater()
getLowWater
in interface MemoryCache
public java.lang.String getName()
getName
in interface MemoryCache
public int getNumObjects()
MemoryCache
MemoryCache
.
getNumObjects
in interface MemoryCache
public java.lang.Object getObject(java.lang.Object key)
getObject
in interface MemoryCache
key
- The key for the object to be found.
java.lang.IllegalArgumentException
- if key
is nullpublic long getUsedCapacity()
MemoryCache
MemoryCache
space. The value returned is in bytes.
getUsedCapacity
in interface MemoryCache
public void remove(java.lang.Object key)
remove
in interface MemoryCache
key
- the key of the object to be removed
java.lang.IllegalArgumentException
- if key
is nullpublic void removeCacheListener(MemoryCache.CacheListener listener)
removeCacheListener
in interface MemoryCache
listener
- The CacheListener
to remove
java.lang.IllegalArgumentException
- if listener
is nullpublic void setCapacity(long newCapacity)
setCapacity
in interface MemoryCache
newCapacity
- the new capacity of the cache.public void setLowWater(long loWater)
setLowWater
in interface MemoryCache
loWater
- the new low water level in bytes.public void setName(java.lang.String name)
setName
in interface MemoryCache
public java.lang.String toString()
String
representation of this object is returned. This representation consists of maximum
size, current used capacity and number of currently cached items.
toString
in class java.lang.Object
String
representation of this object
|
NASA World Wind | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |