org.castor.cache.hashbelt.container

Class WeakReferenceContainer

public final class WeakReferenceContainer extends Object implements Container

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.

Since: 1.0

Version: $Revision: 5951 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $

Author: Gregory Block Ralf Joachim

Method Summary
voidclear()
booleancontainsKey(Object key)
booleancontainsValue(Object value)
SetentrySet()
Objectget(Object key)
longgetTimestamp()
booleanisEmpty()
IteratorkeyIterator()
SetkeySet()
Objectput(Object key, Object value)
voidputAll(Map map)
Objectremove(Object key)
intsize()
voidupdateTimestamp()
IteratorvalueIterator()
Collectionvalues()

Method Detail

clear

public void clear()
{@inheritDoc }

See Also: java.util.Map#clear()

containsKey

public boolean containsKey(Object key)
{@inheritDoc }

See Also: java.util.Map#containsKey(java.lang.Object)

containsValue

public boolean containsValue(Object value)
{@inheritDoc }

See Also: java.util.Map#containsValue(java.lang.Object)

entrySet

public Set entrySet()
{@inheritDoc }

See Also: java.util.Map#entrySet()

get

public Object get(Object key)
{@inheritDoc }

See Also: java.util.Map#get(java.lang.Object)

getTimestamp

public long getTimestamp()
{@inheritDoc }

See Also: getTimestamp

isEmpty

public boolean isEmpty()
{@inheritDoc }

See Also: java.util.Map#isEmpty()

keyIterator

public Iterator keyIterator()
{@inheritDoc }

See Also: keyIterator

keySet

public Set keySet()
{@inheritDoc }

See Also: java.util.Map#keySet()

put

public Object put(Object key, Object value)
{@inheritDoc }

See Also: java.util.Map#put(java.lang.Object, java.lang.Object)

putAll

public void putAll(Map map)
{@inheritDoc }

See Also: java.util.Map#putAll(java.util.Map)

remove

public Object remove(Object key)
{@inheritDoc }

See Also: java.util.Map#remove(java.lang.Object)

size

public int size()
{@inheritDoc }

See Also: java.util.Map#size()

updateTimestamp

public void updateTimestamp()
{@inheritDoc }

See Also: updateTimestamp

valueIterator

public Iterator valueIterator()
{@inheritDoc }

See Also: valueIterator

values

public Collection values()
{@inheritDoc }

See Also: java.util.Map#values()

Intalio Inc. (C) 1999-2006. All rights reserved http://www.intalio.com