Package org.globus.util
Class I18n
- java.lang.Object
-
- org.globus.util.I18n
-
public class I18n extends Object
An utility class for internationalized message handling. Example usage::private static I18n i18n = I18n.getI18n("org.globus.resource"); ... public void hello() { String filename = "file1"; String msg = i18n.getMessage("noFile", new String[]{filename}); ... }
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedI18n(ResourceBundle messages)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static I18ngetI18n(String resource)Retrieve a I18n instance by resource name.static I18ngetI18n(String resource, ClassLoader loader)Retrieve a I18n instance by resource nameStringgetMessage(String key)Gets a message from resource bundle.StringgetMessage(String key, Object arg)Gets a formatted message from resource bundleStringgetMessage(String key, Object[] vars)Gets a formatted message from resource bundle
-
-
-
Constructor Detail
-
I18n
protected I18n(ResourceBundle messages)
-
-
Method Detail
-
getI18n
public static I18n getI18n(String resource)
Retrieve a I18n instance by resource name.- Parameters:
resource- resource name. SeeResourceBundle.getBundle()
-
getI18n
public static I18n getI18n(String resource, ClassLoader loader)
Retrieve a I18n instance by resource name- Parameters:
resource- resource name. SeeResourceBundle.getBundle()loader- the class loader to be used to load the resource. This parameter is only used initially to load the actual resource. Once the resource is loaded, this argument is ignored.
-
getMessage
public String getMessage(String key) throws MissingResourceException
Gets a message from resource bundle.- Throws:
MissingResourceException
-
getMessage
public String getMessage(String key, Object arg) throws MissingResourceException
Gets a formatted message from resource bundle- Throws:
MissingResourceException
-
getMessage
public String getMessage(String key, Object[] vars) throws MissingResourceException
Gets a formatted message from resource bundle- Throws:
MissingResourceException
-
-