triploa
Class LocalizationSupport

java.lang.Object
  extended by triploa.LocalizationSupport

public class LocalizationSupport
extends java.lang.Object


Constructor Summary
LocalizationSupport()
           
 
Method Summary
static java.lang.String getErrorMessage()
          Returns an error message if there was any problem with accessing the localized text.
static java.lang.String getMessage(java.lang.String key)
          Finds a localized string in a message bundle.
static java.lang.String getMessage(java.lang.String key, java.lang.Object[] args)
          Finds a localized string in a message bundle and formats the message by passing requested parameters.
static boolean initLocalizationSupport()
          Initializes localization support based on currently set locale (obtained from "microedition.locale" system property).
static boolean initLocalizationSupport(java.lang.String locale)
          Explicit initialization of the localization support.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalizationSupport

public LocalizationSupport()
Method Detail

initLocalizationSupport

public static boolean initLocalizationSupport()
Initializes localization support based on currently set locale (obtained from "microedition.locale" system property). The initialization method is called automatically when a call to getMessage(java.lang.String) method is attempted for the first time. You can call this method explicitly to see whether there was any problem with initialization of the localization support. Method returns a status of the successfulness. If there was any problem with initialization, you can get reason by using getErrorMessage() method.

Returns:
true if the intialization was succesfull, false if there was any problem.

initLocalizationSupport

public static boolean initLocalizationSupport(java.lang.String locale)
Explicit initialization of the localization support. This method is usually called when a particular locale used in the application. E.g. the application contains only french messages (no default messages, only messages_fr.properties files is available), you should initialize the localization support (by calling initLocalizationSupport("fr");) before using getMessage(java.lang.String) method for the first time. Method returns a status of the successfulness. If there was any problem with the initialization, you can get explanation by using getErrorMessage() method.

Parameters:
locale - locale which will be used to determine which message file from bundle will be used
Returns:
true if the intialization was succesfull, false if there was any problem.

getErrorMessage

public static java.lang.String getErrorMessage()
Returns an error message if there was any problem with accessing the localized text. The message also possibly explainins a reason of the failure. The message is taken from _INIT_LOCALIZATION_ERROR_MSG.

Returns:
error message if there was any failure or null when everything is OK.

getMessage

public static final java.lang.String getMessage(java.lang.String key)
Finds a localized string in a message bundle.

Parameters:
key - key of the localized string to look for
Returns:
the localized string. If key is not found, then _DEFAULT_STRING string is returned

getMessage

public static final java.lang.String getMessage(java.lang.String key,
                                                java.lang.Object[] args)
Finds a localized string in a message bundle and formats the message by passing requested parameters.

Parameters:
key - key of the localized string to look for
args - array of parameters to use for formatting the message
Returns:
the localized string. If key is not found, then _DEFAULT_STRING string is returned