Class DefaultI18N

  • All Implemented Interfaces:
    I18N, org.codehaus.plexus.logging.LogEnabled, org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable

    public class DefaultI18N
    extends org.codehaus.plexus.logging.AbstractLogEnabled
    implements I18N, org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultI18N()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String format​(java.lang.String key, java.lang.Object arg1)  
      java.lang.String format​(java.lang.String key, java.lang.Object arg1, java.lang.Object arg2)  
      java.lang.String format​(java.lang.String bundleName, java.util.Locale locale, java.lang.String key, java.lang.Object arg1)  
      java.lang.String format​(java.lang.String bundleName, java.util.Locale locale, java.lang.String key, java.lang.Object[] args)
      Looks up the value for key in the ResourceBundle referenced by bundleName, then formats that value for the specified Locale using args.
      java.lang.String format​(java.lang.String bundleName, java.util.Locale locale, java.lang.String key, java.lang.Object arg1, java.lang.Object arg2)  
      java.util.ResourceBundle getBundle()  
      java.util.ResourceBundle getBundle​(java.lang.String bundleName)  
      java.util.ResourceBundle getBundle​(java.lang.String bundleName, java.lang.String languageHeader)
      This method returns a ResourceBundle given the bundle name and the Locale information supplied in the HTTP "Accept-Language" header.
      java.util.ResourceBundle getBundle​(java.lang.String bundleName, java.util.Locale locale)
      This method returns a ResourceBundle for the given bundle name and the given Locale.
      java.lang.String[] getBundleNames()  
      java.lang.String getDefaultBundleName()  
      java.lang.String getDefaultCountry()  
      java.lang.String getDefaultLanguage()  
      java.util.Locale getLocale​(java.lang.String header)  
      java.lang.String getString​(java.lang.String key)  
      java.lang.String getString​(java.lang.String key, java.util.Locale locale)  
      java.lang.String getString​(java.lang.String bundleName, java.util.Locale locale, java.lang.String key)  
      protected java.lang.String getStringOrNull​(java.util.ResourceBundle rb, java.lang.String key)
      Gets localized text from a bundle if it's there.
      void initialize()
      Called the first time the Service is used.
      protected void initializeBundleNames()  
      • Methods inherited from class org.codehaus.plexus.logging.AbstractLogEnabled

        enableLogging, getLogger, setupLogger, setupLogger, setupLogger
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultI18N

        public DefaultI18N()
    • Method Detail

      • getDefaultLanguage

        public java.lang.String getDefaultLanguage()
        Specified by:
        getDefaultLanguage in interface I18N
      • getDefaultCountry

        public java.lang.String getDefaultCountry()
        Specified by:
        getDefaultCountry in interface I18N
      • getDefaultBundleName

        public java.lang.String getDefaultBundleName()
        Specified by:
        getDefaultBundleName in interface I18N
      • getBundleNames

        public java.lang.String[] getBundleNames()
        Specified by:
        getBundleNames in interface I18N
      • getBundle

        public java.util.ResourceBundle getBundle()
        Specified by:
        getBundle in interface I18N
      • getBundle

        public java.util.ResourceBundle getBundle​(java.lang.String bundleName)
        Specified by:
        getBundle in interface I18N
      • getBundle

        public java.util.ResourceBundle getBundle​(java.lang.String bundleName,
                                                  java.lang.String languageHeader)
        This method returns a ResourceBundle given the bundle name and the Locale information supplied in the HTTP "Accept-Language" header.
        Specified by:
        getBundle in interface I18N
        Parameters:
        bundleName - Name of bundle.
        languageHeader - A String with the language header.
        Returns:
        A localized ResourceBundle.
      • getBundle

        public java.util.ResourceBundle getBundle​(java.lang.String bundleName,
                                                  java.util.Locale locale)
        This method returns a ResourceBundle for the given bundle name and the given Locale.
        Specified by:
        getBundle in interface I18N
        Parameters:
        bundleName - Name of bundle (or null for the default bundle).
        locale - The locale (or null for the locale indicated by the default language and country).
        Returns:
        A localized ResourceBundle.
      • getString

        public java.lang.String getString​(java.lang.String key)
        Specified by:
        getString in interface I18N
      • getString

        public java.lang.String getString​(java.lang.String key,
                                          java.util.Locale locale)
        Specified by:
        getString in interface I18N
      • getString

        public java.lang.String getString​(java.lang.String bundleName,
                                          java.util.Locale locale,
                                          java.lang.String key)
        Specified by:
        getString in interface I18N
        Throws:
        java.util.MissingResourceException - Specified key cannot be matched.
        See Also:
        I18N.getString(String, Locale, String)
      • format

        public java.lang.String format​(java.lang.String key,
                                       java.lang.Object arg1)
        Specified by:
        format in interface I18N
      • format

        public java.lang.String format​(java.lang.String key,
                                       java.lang.Object arg1,
                                       java.lang.Object arg2)
        Specified by:
        format in interface I18N
      • format

        public java.lang.String format​(java.lang.String bundleName,
                                       java.util.Locale locale,
                                       java.lang.String key,
                                       java.lang.Object[] args)
        Looks up the value for key in the ResourceBundle referenced by bundleName, then formats that value for the specified Locale using args.
        Specified by:
        format in interface I18N
        Returns:
        Localized, formatted text identified by key.
      • initialize

        public void initialize()
                        throws org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
        Called the first time the Service is used.
        Specified by:
        initialize in interface org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable
        Throws:
        org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException
      • initializeBundleNames

        protected void initializeBundleNames()
      • getStringOrNull

        protected final java.lang.String getStringOrNull​(java.util.ResourceBundle rb,
                                                         java.lang.String key)
        Gets localized text from a bundle if it's there. Otherwise, returns null (ignoring a possible MissingResourceException).