org.pm4j.core.pm.impl.title
Class ResStringCache

java.lang.Object
  extended by org.pm4j.core.pm.impl.title.ResStringCache

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).

Author:
olaf boede

Nested Class Summary
static class ResStringCache.Entry
          A structure that holds the cached value.
 
Constructor Summary
ResStringCache()
           
 
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

ResStringCache

public ResStringCache()
Method Detail

find

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

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

put

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

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