org.codehaus.plexus.i18n

Class DefaultI18N

Implemented Interfaces:
I18N, Initializable

public class DefaultI18N
extends AbstractLogEnabled
implements I18N, Initializable

Fields inherited from interface org.codehaus.plexus.i18n.I18N

ACCEPT_LANGUAGE, ROLE

Method Summary

String
format(String bundleName, Locale locale, String key, Object arg1)
String
format(String bundleName, Locale locale, String key, Object arg1, Object arg2)
String
format(String bundleName, Locale locale, String key, Object[] args)
Looks up the value for key in the ResourceBundle referenced by bundleName, then formats that value for the specified Locale using args.
String
format(String key, Object arg1)
String
format(String key, Object arg1, Object arg2)
ResourceBundle
getBundle()
ResourceBundle
getBundle(String bundleName)
ResourceBundle
getBundle(String bundleName, Locale locale)
This method returns a ResourceBundle for the given bundle name and the given Locale.
ResourceBundle
getBundle(String bundleName, String languageHeader)
This method returns a ResourceBundle given the bundle name and the Locale information supplied in the HTTP "Accept-Language" header.
String[]
getBundleNames()
String
getDefaultBundleName()
String
getDefaultCountry()
String
getDefaultLanguage()
Locale
getLocale(String header)
String
getString(String key)
String
getString(String key, Locale locale)
String
getString(String bundleName, Locale locale, String key)
protected String
getStringOrNull(ResourceBundle rb, 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()

Method Details

format

public String format(String bundleName,
                     Locale locale,
                     String key,
                     Object arg1)
Specified by:
format in interface I18N

format

public String format(String bundleName,
                     Locale locale,
                     String key,
                     Object arg1,
                     Object arg2)
Specified by:
format in interface I18N

format

public String format(String bundleName,
                     Locale locale,
                     String key,
                     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.

format

public String format(String key,
                     Object arg1)
Specified by:
format in interface I18N

format

public String format(String key,
                     Object arg1,
                     Object arg2)
Specified by:
format in interface I18N

getBundle

public ResourceBundle getBundle()
Specified by:
getBundle in interface I18N

getBundle

public ResourceBundle getBundle(String bundleName)
Specified by:
getBundle in interface I18N

getBundle

public ResourceBundle getBundle(String bundleName,
                                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.

getBundle

public ResourceBundle getBundle(String bundleName,
                                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.

getBundleNames

public String[] getBundleNames()
Specified by:
getBundleNames in interface I18N

getDefaultBundleName

public String getDefaultBundleName()
Specified by:
getDefaultBundleName in interface I18N

getDefaultCountry

public String getDefaultCountry()
Specified by:
getDefaultCountry in interface I18N

getDefaultLanguage

public String getDefaultLanguage()
Specified by:
getDefaultLanguage in interface I18N

getLocale

public Locale getLocale(String header)
Specified by:
getLocale in interface I18N

getString

public String getString(String key)
Specified by:
getString in interface I18N

getString

public String getString(String key,
                        Locale locale)
Specified by:
getString in interface I18N

getString

public String getString(String bundleName,
                        Locale locale,
                        String key)
Specified by:
getString in interface I18N

getStringOrNull

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

initialize

public void initialize()
            throws InitializationException
Called the first time the Service is used.

initializeBundleNames

protected void initializeBundleNames()