Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| xmlgraphics-commons 1.5
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.xmlgraphics.image.loader.util
Class SoftMapCache

    java.lang.Object
      org.apache.xmlgraphics.image.loader.util.SoftMapCache

    public class SoftMapCache

extends Object

Provides a simple cache using soft references and storing the values in a Map. The keys into the Map are hard references, the values are referenced through soft references. The collected values are cleaned up through a ReferenceQueue.

Constructor Summary
`SoftMapCache(boolean synched)` Creates a new soft cache.

Method Summary
`void` | `clear()` Clears the cache.
`void` | `doHouseKeeping()` Triggers some house-keeping, i.e.
`Object` | `get(Object key)` Returns the value associated with the given key.
`void` | `put(Object key, Object value)` Put a new value in the cache overwriting any existing value with the same key.
`Object` | `remove(Object key)` Removed the value associated with the given key.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SoftMapCache

    public SoftMapCache(boolean synched)

  Creates a new soft cache.

  Parameters:
    `synched` - true if the Map containing the values should by synchronized

Method Detail

### get

    public Object get(Object key)

  Returns the value associated with the given key. If the value is not found or the value has been collected, null is returned.

  Parameters:
    `key` - the key
  Returns:
    the requested value or null

### remove

    public Object remove(Object key)

  Removed the value associated with the given key. The value that is removed is returned as the methods result. If the value is not found or the value has been collected, null is returned.

  Parameters:
    `key` - the key
  Returns:
    the requested value or null

### put

    public void put(Object key,
                    Object value)

  Put a new value in the cache overwriting any existing value with the same key.

  Parameters:
    `key` - The key
    `value` - the value

### clear

    public void clear()

  Clears the cache.

### doHouseKeeping

    public void doHouseKeeping()

  Triggers some house-keeping, i.e. processes any pending objects in the reference queue.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| xmlgraphics-commons 1.5
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 1999-2012 The Apache Software Foundation. All Rights Reserved.