org.apache.xmlgraphics.image.loader.util

## Class SoftMapCache

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

-     public class SoftMapCache
      extends java.lang.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

    Constructors
    Constructor and Description
    `SoftMapCache(boolean synched)` Creates a new soft cache.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()` Clears the cache.
    `void` | `doHouseKeeping()` Triggers some house-keeping, i.e.
    `java.lang.Object` | `get(java.lang.Object key)` Returns the value associated with the given key.
    `void` | `put(java.lang.Object key, java.lang.Object value)` Put a new value in the cache overwriting any existing value with the same key.
    `java.lang.Object` | `remove(java.lang.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 java.lang.Object get(java.lang.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 java.lang.Object remove(java.lang.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(java.lang.Object key,
                          java.lang.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.

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