org.norther.tammi.core.locale
Interface ResourceFinder

All Superinterfaces:
CacheClient, Refreshable
All Known Implementing Classes:
DefaultResourceFinder

public interface ResourceFinder
extends CacheClient

An interface to localized resource finders. A resource finder searches first for localized property files from the resource folders and the classpath in the following order:

 'lang'_'country'_'variant' 
 _'counry'_'variant' 
 'lang'__'variant'
 __'variant' 
 'lang'_'country' 
 _'country' 
 'lang' 
 
If no resources are found, it applies the search mechanism of java.util.ResourceBundle.

Author:
Ilkka Priha

Method Summary
 long getCacheCleared()
          Gets the timestamp of the last cache clearing or expiration.
 String getDefaultBaseName()
          Gets the default base name to be applied when an explicit one is not specified.
 String getDefaultEncoding()
          Gets the encoding to use for property files.
 Locale getDefaultLocale()
          Gets the default locale of resources.
 String getPlugInBaseName(String key)
          Gets the base name of the resource bundle class associated with the specified plug-in key.
 String getPlugInKey()
          Gets the default key for pluggable resource bundles of this resource finder.
 String getPlugInKey(Class baseClass)
          Gets the most specific key for pluggable resource bundles of this resource finder.
 String getPlugInKey(String baseName)
          Gets the class specific key for pluggable resource bundles of this resource finder.
 LookupResourceBundle getResourceBundle()
          Gets the default resource bundle for the default base name.
 LookupResourceBundle getResourceBundle(Locale locale)
          Gets the default resource bundle for the default base name and the specified locale.
 LookupResourceBundle getResourceBundle(String baseName)
          Gets the appropriate resource bundle for the given base name.
 LookupResourceBundle getResourceBundle(String baseName, Locale locale)
          Gets the appropriate resource bundle for the given base name and specified locale.
 LookupResourceBundle getResourceBundle(String baseName, Locale locale, ClassLoader loader)
          Gets the appropriate resource bundle for the given base name, specified locale and class loader.
 LookupResourceBundle getResourceBundle(String baseName, Locale locale, String variant)
          Gets the appropriate resource bundle for the given base name, specified locale and optional variant.
 LookupResourceBundle getResourceBundle(String baseName, Locale locale, String variant, ClassLoader loader)
          Gets the appropriate resource bundle for the given base name, specified locale, optional variant and class loader.
 long getResourceCheckInterval()
          Gets the default interval for checking validity of cached resource bundles of this resource finder.
 long getResourceCheckInterval(Class baseClass)
          Gets the most specific interval for checking validity of cached resource bundles of this resource finder.
 long getResourceCheckInterval(String className)
          Gets the class specific interval for checking validity of cached resource bundles of this resource finder.
 String getResourceKey()
          Gets the path finder key for resolving resource paths.
 void setDefaultBaseName(String baseName)
          Sets the default base name to be applied when an explicit one is not specified.
 void setDefaultEncoding(String encoding)
          Sets the encoding to use for property files.
 void setDefaultLocale(Locale locale)
          Sets the default locale of resources.
 void setPlugInKey(String key)
          Sets the default key for pluggable resource bundles of this resource finder.
 void setPlugInKey(String baseName, String key)
          Sets the default key for pluggable resource bundles of this resource finder.
 void setResourceCheckInterval(long msecs)
          Sets the default interval for checking validity of cached resource bundles of this resource finder.
 void setResourceCheckInterval(String className, long msecs)
          Sets the class specific interval of checking validity of cached resource bundles of this resource finder.
 void setResourceKey(String key)
          Sets the path finder key for resolving resource paths.
 
Methods inherited from interface org.norther.tammi.core.cache.CacheClient
clearCached, expireCached, expireFraction, getCache, isCachingDisabled, removeCache, setCachingDisabled
 
Methods inherited from interface org.norther.tammi.core.base.Refreshable
getRefreshed, refresh
 

Method Detail

getDefaultBaseName

String getDefaultBaseName()
Gets the default base name to be applied when an explicit one is not specified.

Returns:
the default base name or null.

setDefaultBaseName

void setDefaultBaseName(String baseName)
Sets the default base name to be applied when an explicit one is not specified.

Parameters:
baseName - the default base name.

getDefaultLocale

Locale getDefaultLocale()
Gets the default locale of resources.

Returns:
the default locale.

setDefaultLocale

void setDefaultLocale(Locale locale)
Sets the default locale of resources. The locale also specifies the character encoding, if it is not given separately.

Parameters:
locale - the default locale.

getDefaultEncoding

String getDefaultEncoding()
Gets the encoding to use for property files.

Returns:
the encoding for property files.

setDefaultEncoding

void setDefaultEncoding(String encoding)
Sets the encoding to use for property files. If not specified, the encoding for the corresponding locale will be applied.

Parameters:
encoding - the encoding for property files.

getResourceKey

String getResourceKey()
Gets the path finder key for resolving resource paths.

Returns:
the path finder key.

setResourceKey

void setResourceKey(String key)
Sets the path finder key for resolving resource paths. The default key is PathFinderMBean.RESOURCE.

Parameters:
key - the path finder key.

getPlugInKey

String getPlugInKey()
Gets the default key for pluggable resource bundles of this resource finder.

Returns:
the plug-in key or null.

setPlugInKey

void setPlugInKey(String key)
Sets the default key for pluggable resource bundles of this resource finder.

Parameters:
key - the plug-in key.

getPlugInKey

String getPlugInKey(String baseName)
Gets the class specific key for pluggable resource bundles of this resource finder.

Parameters:
baseName - the base name of the resource bundle class.
Returns:
the plug-in key or null.

setPlugInKey

void setPlugInKey(String baseName,
                  String key)
Sets the default key for pluggable resource bundles of this resource finder.

Parameters:
baseName - the base name of the resource bundle class.
key - the plug-in key.

getPlugInKey

String getPlugInKey(Class baseClass)
Gets the most specific key for pluggable resource bundles of this resource finder.

Parameters:
baseClass - the base class of the resource bundle.
Returns:
the plug-in key or null.

getPlugInBaseName

String getPlugInBaseName(String key)
Gets the base name of the resource bundle class associated with the specified plug-in key.

Note that if there are several base names associated with the same key, an arbitrary one of the alternatives is returned.

Parameters:
key - the plug-in key.
Returns:
the base name of the resource bundle class.

getResourceCheckInterval

long getResourceCheckInterval()
Gets the default interval for checking validity of cached resource bundles of this resource finder.

Returns:
the resource check interval in milliseconds.

setResourceCheckInterval

void setResourceCheckInterval(long msecs)
Sets the default interval for checking validity of cached resource bundles of this resource finder.

Parameters:
msecs - the check interval in milliseconds (-1 = only once).

getResourceCheckInterval

long getResourceCheckInterval(String className)
Gets the class specific interval for checking validity of cached resource bundles of this resource finder.

Parameters:
className - the base name of the resource bundle class.
Returns:
the resource check interval in milliseconds.

getResourceCheckInterval

long getResourceCheckInterval(Class baseClass)
Gets the most specific interval for checking validity of cached resource bundles of this resource finder.

Parameters:
baseClass - the base class of the resource bundle.
Returns:
the resource check interval in milliseconds.

setResourceCheckInterval

void setResourceCheckInterval(String className,
                              long msecs)
Sets the class specific interval of checking validity of cached resource bundles of this resource finder.

Parameters:
className - the base name of the resource bundle class.
msecs - the check interval in milliseconds (-1 = only once).

getResourceBundle

LookupResourceBundle getResourceBundle()
Gets the default resource bundle for the default base name.

Returns:
the resource bundle or null.

getResourceBundle

LookupResourceBundle getResourceBundle(Locale locale)
Gets the default resource bundle for the default base name and the specified locale.

Parameters:
locale - the locale to apply.
Returns:
the resource bundle or null.

getResourceBundle

LookupResourceBundle getResourceBundle(String baseName)
Gets the appropriate resource bundle for the given base name.

Parameters:
baseName - the base name of the resource bundle.
Returns:
the resource bundle or null.

getResourceBundle

LookupResourceBundle getResourceBundle(String baseName,
                                       Locale locale)
Gets the appropriate resource bundle for the given base name and specified locale.

Parameters:
baseName - the base name of the resource bundle.
locale - the locale to apply.
Returns:
the resource bundle or null.

getResourceBundle

LookupResourceBundle getResourceBundle(String baseName,
                                       Locale locale,
                                       String variant)
Gets the appropriate resource bundle for the given base name, specified locale and optional variant. If the optional variant is not null, the one in the locale is replaced with the given variant.

Parameters:
baseName - the base name of the resource bundle.
locale - the locale to apply.
variant - an optional variant.
Returns:
the resource bundle or null.

getResourceBundle

LookupResourceBundle getResourceBundle(String baseName,
                                       Locale locale,
                                       ClassLoader loader)
Gets the appropriate resource bundle for the given base name, specified locale and class loader.

Parameters:
baseName - the base name of the resource bundle.
locale - the locale to apply.
loader - the class loader to load the resource from.
Returns:
the resource bundle or null.

getResourceBundle

LookupResourceBundle getResourceBundle(String baseName,
                                       Locale locale,
                                       String variant,
                                       ClassLoader loader)
Gets the appropriate resource bundle for the given base name, specified locale, optional variant and class loader. If the optional variant is not null, the one in the locale is replaced with the given variant.

Parameters:
baseName - the base name of the resource bundle.
locale - the locale to apply.
variant - an optional variant.
loader - the class loader to load the resource from.
Returns:
the resource bundle or null.

getCacheCleared

long getCacheCleared()
Gets the timestamp of the last cache clearing or expiration.

Returns:
the timestamp of the last cache clearing.


Copyright © 2004 The Norther Organization. All rights reserved.