com.taco.util
Class CachedKeysResourceBundle

java.lang.Object
  extended by java.util.ResourceBundle
      extended by com.taco.util.AccessibleResourceBundle
          extended by com.taco.util.CachedKeysResourceBundle
Direct Known Subclasses:
AccessibleResourceBundleAdapter, MultiLinePropertyResourceBundle, UIManagerResourceBundle

public abstract class CachedKeysResourceBundle
extends AccessibleResourceBundle

A subclass of AccessibleResourceBundle that provides a useful implementation of getKeys().


Field Summary
protected  java.util.Set _cachedKeySet
          If _useSoftCache is false, this field maintains a strong reference to the key set computed the first time getKeys() is called.
protected  java.lang.ref.SoftReference _keySetRef
          If _useSoftCache is false, this field is soft reference to the key set computed the first time getKeys() is called.
protected  boolean _useSoftCache
          A flag indicating whether a soft reference to the key set should be maintained in _keySetRef.
 
Fields inherited from class com.taco.util.AccessibleResourceBundle
_isParentSet, _locale
 
Fields inherited from class java.util.ResourceBundle
parent
 
Constructor Summary
CachedKeysResourceBundle()
          Create a new instance that uses a soft reference to store the previously computed set of keys, so the key set can be garbage collected if necessary.
CachedKeysResourceBundle(boolean useSoftCache)
          Create a new instance that uses a cache to store the previously computed set of keys.
 
Method Summary
protected abstract  java.util.Iterator _getProperKeys()
          Return an iteration over the keys defined by this bundle only, not by its parents.
 java.util.Enumeration getKeys()
          If the key set has not been cached, compute the key set by first adding all of the parent's keys to the key set, then adding all this bundle's keys (returned by _getProperKeys()).
 boolean getUseSoftCache()
          Return true if this instance uses a soft reference to cache the key set.
 void invalidateCache()
          Invalidate the cache of the key set.
 void setUseSoftCache(boolean useSoftCache)
          Switch the caching mode.
 
Methods inherited from class com.taco.util.AccessibleResourceBundle
getLocale, getParent, setLocale, setParent
 
Methods inherited from class java.util.ResourceBundle
getBundle, getBundle, getBundle, getObject, getString, getStringArray, handleGetObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_useSoftCache

protected boolean _useSoftCache
A flag indicating whether a soft reference to the key set should be maintained in _keySetRef. Otherwise, a strong reference is maintained in _cachedKeySet.


_keySetRef

protected java.lang.ref.SoftReference _keySetRef
If _useSoftCache is false, this field is soft reference to the key set computed the first time getKeys() is called. If null, the key set hasn't been computed yet.


_cachedKeySet

protected java.util.Set _cachedKeySet
If _useSoftCache is false, this field maintains a strong reference to the key set computed the first time getKeys() is called. If null, the key set hasn't been computed yet.

Constructor Detail

CachedKeysResourceBundle

public CachedKeysResourceBundle()
Create a new instance that uses a soft reference to store the previously computed set of keys, so the key set can be garbage collected if necessary.


CachedKeysResourceBundle

public CachedKeysResourceBundle(boolean useSoftCache)
Create a new instance that uses a cache to store the previously computed set of keys. If useSoftCache is true, the cache is implemented as a soft reference so the key set can be garbage collected if necessary.

Method Detail

getKeys

public java.util.Enumeration getKeys()
If the key set has not been cached, compute the key set by first adding all of the parent's keys to the key set, then adding all this bundle's keys (returned by _getProperKeys()). Return an Enumeration over the key set's elements.

Specified by:
getKeys in class java.util.ResourceBundle

invalidateCache

public void invalidateCache()
Invalidate the cache of the key set. Subclasses may want to invalidate the cache of all mappings as well.


getUseSoftCache

public boolean getUseSoftCache()
Return true if this instance uses a soft reference to cache the key set.


setUseSoftCache

public void setUseSoftCache(boolean useSoftCache)
Switch the caching mode.


_getProperKeys

protected abstract java.util.Iterator _getProperKeys()
Return an iteration over the keys defined by this bundle only, not by its parents. This method is called by getKeys().