de.caff.i18n

## Class DefaultI18n

- java.lang.Object
- - de.caff.i18n.I18n
  - - de.caff.i18n.DefaultI18n

-     public class DefaultI18n
      extends I18n

  Application specific support for internationalization, used for Java 1.2+. This uses the weak reference feature to allow for easier garbage collection.
  Author:
    Rammi

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.List<java.lang.String>` | `appResourceBases` The resource bases.
    `protected java.util.Locale` | `defaultLocale` The default locale.
    `protected java.util.List<java.lang.ref.WeakReference<Localizable>>` | `localizables` Collection of known localizables, which have to be informed of localization changes.
    `protected java.util.Map<java.util.Locale,ResourceBundleCollection>` | `resourceBundles` The resource bundles.

    - ### Fields inherited from class de.caff.i18n.I18n

      `ACTION_SUFFIX, DEBUG, SUFFIX_ACCELERATOR, SUFFIX_DESCRIPTION, SUFFIX_DISABLED_ICON, SUFFIX_ICON, SUFFIX_INACTIVE_ICON, SUFFIX_MNEMONIC, SUFFIX_TEXT, SUFFIX_TOOLTIP`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultI18n()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `_addAppResourceBase(java.lang.String base, boolean prepend)` Add an application specific resource class base name.
    `protected void` | `_addLocalizationChangeListener(Localizable localizable)` Add a listener for localization changes.
    `protected void` | `_dumpResources(java.io.PrintStream out, java.util.Locale locale)` Dump the complete currently known i18n resources for a given locale.
    `protected void` | `_fireLocaleChanged(java.util.Locale locale)` Tell all registered localizables of localization changes.
    `protected java.util.ResourceBundle` | `_getBundle(java.util.Locale l)` Get a ResourceBundle for a locale.
    `protected java.util.Locale` | `_getDefaultLocale()` Get the locale to be used as a default for the application.
    `protected java.util.ResourceBundle` | `_getFallbackBundle()` Get the fallback resource bundle.
    `protected void` | `_removeLocalizationChangeListener(Localizable localizable)` Remove a listener for localization changes.
    `protected void` | `_setDefaultLocale(java.util.Locale l)` Set the locale to be used as a default for the application.

    - ### Methods inherited from class de.caff.i18n.I18n

      `addAppResourceBase, addAppResourceBase, addLocalizationChangeListener, dump, format, format, getDefaultLocale, getFormattedString, getFormattedString, getIcon, getIcon, getString, getString, removeLocalizationChangeListener, setDefaultLocale`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### resourceBundles

          protected final java.util.Map<java.util.Locale,ResourceBundleCollection> resourceBundles

      The resource bundles.

    - #### appResourceBases

          protected final java.util.List<java.lang.String> appResourceBases

      The resource bases.

    - #### defaultLocale

          protected java.util.Locale defaultLocale

      The default locale.

    - #### localizables

          protected final java.util.List<java.lang.ref.WeakReference<Localizable>> localizables

      Collection of known localizables, which have to be informed of localization changes.

      The localizables are only weakly referenced here.

  - ### Constructor Detail

    - #### DefaultI18n

          public DefaultI18n()

  - ### Method Detail

    - #### _addAppResourceBase

          protected void _addAppResourceBase(@NotNull
                                             java.lang.String base,
                                             boolean prepend)

      Add an application specific resource class base name. This should be called by any application/applet before any other i18n specific code is used.
      Specified by:
        `_addAppResourceBase` in class `I18n`
      Parameters:
        `base` - base class name for resources
        `prepend` - prepend this resource base?
      See Also:
        `ResourceBundle`

    - #### _setDefaultLocale

          protected void _setDefaultLocale(java.util.Locale l)

      Set the locale to be used as a default for the application.
      Specified by:
        `_setDefaultLocale` in class `I18n`
      Parameters:
        `l` - locale to be used as default

    - #### _getDefaultLocale

          @NotNull
          protected java.util.Locale _getDefaultLocale()

      Get the locale to be used as a default for the application.
      Specified by:
        `_getDefaultLocale` in class `I18n`
      Returns:
        locale to be used as default

    - #### _getBundle

          @NotNull
          protected java.util.ResourceBundle _getBundle(@Nullable
                                                                 java.util.Locale l)

      Get a ResourceBundle for a locale.
      Specified by:
        `_getBundle` in class `I18n`
      Parameters:
        `l` - locale
      Returns:
        ResourceBundle for that Locale
      Throws:
        `java.util.MissingResourceException` - when no appResourceBase is set

    - #### _getFallbackBundle

          protected java.util.ResourceBundle _getFallbackBundle()

      Get the fallback resource bundle.
      Specified by:
        `_getFallbackBundle` in class `I18n`
      Returns:
        fallback bundle

    - #### _addLocalizationChangeListener

          protected void _addLocalizationChangeListener(@NotNull
                                                        Localizable localizable)

      Add a listener for localization changes.
      Specified by:
        `_addLocalizationChangeListener` in class `I18n`
      Parameters:
        `localizable` - listener for changes

    - #### _removeLocalizationChangeListener

          protected void _removeLocalizationChangeListener(@NotNull
                                                           Localizable localizable)

      Remove a listener for localization changes.
      Specified by:
        `_removeLocalizationChangeListener` in class `I18n`
      Parameters:
        `localizable` - listener to be removed

    - #### _fireLocaleChanged

          protected void _fireLocaleChanged(java.util.Locale locale)

      Tell all registered localizables of localization changes.
      Specified by:
        `_fireLocaleChanged` in class `I18n`
      Parameters:
        `locale` - new locale

    - #### _dumpResources

          protected void _dumpResources(@NotNull
                                        java.io.PrintStream out,
                                        @Nullable
                                        java.util.Locale locale)

      Dump the complete currently known i18n resources for a given locale.
      Specified by:
        `_dumpResources` in class `I18n`
      Parameters:
        `out` - print stream where to dump to
        `locale` - locale for which to dump the resources