Class ResStringCache

  extended by

public class ResStringCache
extends java.lang.Object

A cache for string resource values.

Hint for null value handling: If you don't have a value for a given resource, you may put a null value for the given key to this cache. This way you get next time for the same key an ResStringCache.Entry with a null value. You have only to scan the potentially slow localization datasource (file, db etc.) when get no entry back from find(String, Locale).

olaf boede

Nested Class Summary
static class ResStringCache.Entry
          A structure that holds the cached value.
Constructor Summary
Method Summary
 ResStringCache.Entry find(java.lang.String key, java.util.Locale locale)
          Finds an entry for the given key and locale.
 ResStringCache.Entry put(java.lang.String key, java.util.Locale locale, java.lang.String value)
          Puts a cache entry.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public ResStringCache()
Method Detail


public ResStringCache.Entry find(java.lang.String key,
                                 java.util.Locale locale)
Finds an entry for the given key and locale.

key - The resource key.
locale - The locale to find a value for.
An ResStringCache.Entry if there is a cache entry for the given key-locale combination. Otherwise null.


public ResStringCache.Entry put(java.lang.String key,
                                java.util.Locale locale,
                                java.lang.String value)
Puts a cache entry.

key - The resource key.
locale - The locale for the given value.
value - The locale specific value.
The new resource entry.