| java.lang.Object org.isqlviewer.util.LocalMessages
LocalMessages | final public class LocalMessages (Code) | | Create localized formated/unformatted messages from ResourceBundles.
This class is mainly designed to take alot of the grunt work for making an application localized while still taking
advantage of the MessageFormat object as much as possible.
This object implements a caching mechanisim at a global level as well as local level so that effeciency is maximized
for resuing message formats whenever possible.
author: Markus A. Kobold. version: 1.0 |
Method Summary | |
public String | format(String message) Gets a localized message that does not require formatting.
Parameters: message - the bundle key to get the localized message. | public String | format(String message, Object... args) Formats a message from the local bundle with variant number of arguments.
This is the heart of this object for formatting localized messages. | public String | getMessage(String message) Gets a localized message that does not require formatting.
Parameters: message - the bundle key to get the localized message. | protected void | init() This will initialize caches and actually attempt to load the bundle. | public static void | setSystemLocale(Locale locale) |
LocalMessages | public LocalMessages(String resourceName)(Code) | | |
LocalMessages | public LocalMessages(String resourceName, Locale preferredLocale)(Code) | | Creates a new Message object with a given resource bundle name.
This will initialize the local caches and detect if the ResourceBundle has already been loaded. If a cached
ResourceBundle is detected all cached MessageFormats are used as well.
The resourceName parameters will have the text '.properties' appended to be used as a fulle bundle name.
For instance:
new Message("com.solutionary.util.resources.LocalMessages"); *
There
would have to be a resource bundle located in '/com/solutionary/util/resource/LocalMessages.properties'
Parameters: resourceName - common name for the resource bundle. Parameters: preferredLocale - the default locale to use for this bundle. |
format | public String format(String message)(Code) | | Gets a localized message that does not require formatting.
Parameters: message - the bundle key to get the localized message. localized message. |
format | public String format(String message, Object... args)(Code) | | Formats a message from the local bundle with variant number of arguments.
This is the heart of this object for formatting localized messages. The locales are first synchronized to ensure
that there is no contention between differnt locales.
Afterwards the MessgeFormat objects that have been pre-compiled in a matter of speaking are queried based on the
message key, if a cached format is found then that instance is used, otherwise a new one is created to format the
local message and return it and then cache the format object.
Parameters: message - resource bundle key to format. Parameters: args - list of object to be used in the formatting pattern. formatted localized string. See Also: MessageFormat.format(java.lang.Stringjava.lang.Object[]) |
getMessage | public String getMessage(String message)(Code) | | Gets a localized message that does not require formatting.
Parameters: message - the bundle key to get the localized message. localized message. |
init | protected void init()(Code) | | This will initialize caches and actually attempt to load the bundle.
|
setSystemLocale | public static void setSystemLocale(Locale locale)(Code) | | |
|
|