|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.castor.cache.hashbelt.container.WeakReferenceContainer
public final class WeakReferenceContainer
An implementation of a container that uses weak references for storing values in the map, so that values can be removed from the map by the system when the system is under memory pressure. Keys, however, are kept strong - so contains() may well find an element, but the value may have been lost. Make sure you test for null returns from put.
Note that keys are hard references; in a situation where OutOfMemory will occur, the JVM will first wipe out all unreferenced objects whose only link is a weak reference. An out of memory will wipe all values from the maps which are currently unreferenced. The keys remain until the hashbelt containers are garbage collected, an put is called with that key or when the value should be accessed through any operation of the Container interface.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
Map.Entry<K,V> |
| Constructor Summary | |
|---|---|
WeakReferenceContainer()
|
|
| Method Summary | |
|---|---|
void |
clear()
|
boolean |
containsKey(Object key)
|
boolean |
containsValue(Object value)
|
Set<Map.Entry<Object,Object>> |
entrySet()
|
Object |
get(Object key)
|
long |
getTimestamp()
Returns the timestamp of this container. |
boolean |
isEmpty()
|
Iterator<Object> |
keyIterator()
Returns an iterator over the keys contained in this container. |
Set<Object> |
keySet()
|
Object |
put(Object key,
Object value)
|
void |
putAll(Map<? extends Object,? extends Object> map)
|
Object |
remove(Object key)
|
int |
size()
|
void |
updateTimestamp()
Set the timestamp of this container to System.currentTimeMillis(). |
Iterator<Object> |
valueIterator()
Returns an iterator over the values contained in this container. |
Collection<Object> |
values()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
equals, hashCode |
| Constructor Detail |
|---|
public WeakReferenceContainer()
| Method Detail |
|---|
public void updateTimestamp()
updateTimestamp in interface Containerpublic long getTimestamp()
getTimestamp in interface Containerpublic Iterator<Object> keyIterator()
keyIterator in interface Containerpublic Iterator<Object> valueIterator()
valueIterator in interface Containerpublic int size()
size in interface Map<Object,Object>public boolean isEmpty()
isEmpty in interface Map<Object,Object>public boolean containsKey(Object key)
containsKey in interface Map<Object,Object>public boolean containsValue(Object value)
containsValue in interface Map<Object,Object>public Object get(Object key)
get in interface Map<Object,Object>
public Object put(Object key,
Object value)
put in interface Map<Object,Object>public Object remove(Object key)
remove in interface Map<Object,Object>public void putAll(Map<? extends Object,? extends Object> map)
putAll in interface Map<Object,Object>public void clear()
clear in interface Map<Object,Object>public Set<Object> keySet()
keySet in interface Map<Object,Object>public Collection<Object> values()
values in interface Map<Object,Object>public Set<Map.Entry<Object,Object>> entrySet()
entrySet in interface Map<Object,Object>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||