Class PropertyCache<T>

java.lang.Object
org.apache.fop.fo.properties.PropertyCache<T>
Type Parameters:
T - The type of values that are cached

public final class PropertyCache<T> extends Object
Thread-safe cache that minimizes the memory requirements by fetching an instance from the cache that is equal to the given one. Internally the instances are stored in WeakReferences in order to be reclaimed when they are no longer referenced.
  • Constructor Details

    • PropertyCache

      public PropertyCache()
      Creates a new cache. The "org.apache.fop.fo.properties.use-cache" system property is used to determine whether properties should actually be cached or not. If not, then the fetch(Object) method will simply return its argument. To enable the cache, set this property to "true" (case insensitive).
  • Method Details

    • fetch

      public T fetch(T obj)
      Returns a cached version of the given object. If the object is not yet in the cache, it will be added and then returned.
      Parameters:
      obj - an object
      Returns:
      a cached version of the object