Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.portal.common.i18n
Class ResourceBundleManager

    java.lang.Object
      org.jboss.portal.common.i18n.ResourceBundleManager

    public class ResourceBundleManager

extends java.lang.Object

Manage a set of resource bundles. Obtention of bundles is delegated to a ResourceBundleFactory. A bundle obtained successfully is cached in order to avoid the potential expensive cost of the bundle retrieval.

The manager can also be used to build LocalizedString object from the loaded bundles.

Version:
  $Revision: 7228 $
Author:
  Julien Viet, Thomas Heute

Constructor Summary
`ResourceBundleManager(java.util.ResourceBundle defaultBundle, ResourceBundleFactory resourceBundleFactory)`

Method Summary
`LocalizedString` | `getLocalizedValue(java.lang.String key, java.lang.String defaultValue)` Return a localized value constructed from the various resource bundles.
`java.util.ResourceBundle` | `getResourceBundle(java.util.Locale locale)` Return a bundle for the given locale.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ResourceBundleManager

    public ResourceBundleManager(java.util.ResourceBundle defaultBundle,
                                 ResourceBundleFactory resourceBundleFactory)
                          throws java.lang.IllegalArgumentException

Parameters:
  `defaultBundle` - the default bundle returned when no bundle has been obtained for the locale
  `resourceBundleFactory` - the resource bundle factory
Throws:
  `java.lang.IllegalArgumentException` - IllegalArgumentException if the resource bundle factory is null

Method Detail

### getLocalizedValue

    public LocalizedString getLocalizedValue(java.lang.String key,
                                             java.lang.String defaultValue)
                                      throws java.lang.IllegalArgumentException

  Return a localized value constructed from the various resource bundles. The supported locales of the manager are used in combination with the specified key. The default value is used if no value is found for the `Locale.ENGLISH`. Two successive calls to this method may not return identical results since the returned `LocalizedString` is built using the bundles known by the manager.

  Parameters:
    `key` - the key to lookup in the bundles
    `defaultValue` - the default value
  Returns:
    the localized string
  Throws:
    `java.lang.IllegalArgumentException` - if the key of the default value is null

### getResourceBundle

    public java.util.ResourceBundle getResourceBundle(java.util.Locale locale)
                                               throws java.lang.IllegalArgumentException

  Return a bundle for the given locale. If the complete locale (language + country + variant) does not exist then it falls back to (language + country) or (language) or the default file.

  When the resource bundle object is found and was not in the global map, it put it in that map with a copy on write.

  Parameters:
    `locale` - the locale we want a bundle for
  Returns:
    a bundle for the locale or null if not suitable bundle is found.
  Throws:
    `java.lang.IllegalArgumentException` - if the locale is null

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008. All Rights Reserved.