anon.util
Class JAPMessages

java.lang.Object
  extended by anon.util.JAPMessages

public final class JAPMessages
extends java.lang.Object

Use this class to display GUI texts in the user's language. The texts Strings are loaded from properties files, so-called Resource Bundles. The default resource bundle is english and its name ends with '_en.properties'. Resource bundle files in other languages must have language specific endings as given by ISO 639. The default resource bundle must always be present and must contain all language strings. The other bundles may contain a subset of these strings.

See Also:
http://www.w3.org/WAI/ER/IG/ert/iso639.htm

Field Summary
private static java.util.Hashtable ms_cachedMessages
           
private static java.util.ResourceBundle ms_defaultResourceBundle
           
private static java.util.Locale ms_locale
           
private static java.util.ResourceBundle ms_resourceBundle
           
private static java.lang.Object SYNC
           
private static java.util.Locale SYSTEM_LOCALE
           
 
Constructor Summary
private JAPMessages()
           
 
Method Summary
private static java.lang.String getBundleLocalisedFilename(java.lang.String a_resourceBundleFilename, java.util.Locale a_locale)
           
static java.util.Locale getLocale()
          Returns the Locale that is used by this class to get the messages.
static java.lang.String getString(java.lang.String a_key)
          Gets the localised String for a given key.
static java.lang.String getString(java.lang.String a_key, java.lang.Object a_argument)
          Gets the localised String for a given key.
static java.lang.String getString(java.lang.String a_key, java.lang.Object[] a_arguments)
          Gets the localised String for a given key.
static java.util.Locale getSystemLocale()
           
static boolean init(java.util.Locale locale, java.lang.String a_resourceBundleFilename)
          Initialises the resource bundle with the specified Locale.
static boolean init(java.lang.String a_resourceBundleFilename)
          Initialises the resource bundle with the System default Locale.
static boolean isInitialised()
           
static void setLocale(java.util.Locale a_locale)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ms_resourceBundle

private static java.util.ResourceBundle ms_resourceBundle

ms_defaultResourceBundle

private static java.util.ResourceBundle ms_defaultResourceBundle

ms_locale

private static java.util.Locale ms_locale

SYSTEM_LOCALE

private static final java.util.Locale SYSTEM_LOCALE

ms_cachedMessages

private static java.util.Hashtable ms_cachedMessages

SYNC

private static final java.lang.Object SYNC
Constructor Detail

JAPMessages

private JAPMessages()
Method Detail

getSystemLocale

public static java.util.Locale getSystemLocale()

init

public static boolean init(java.lang.String a_resourceBundleFilename)
Initialises the resource bundle with the System default Locale. The initialisation may be repeated with a new Locale.

Parameters:
a_resourceBundleFilename - a file name for the resource bundle; the language code for the locale will be added programmatically (e.g. _en, _de, ...).

getBundleLocalisedFilename

private static java.lang.String getBundleLocalisedFilename(java.lang.String a_resourceBundleFilename,
                                                           java.util.Locale a_locale)

init

public static boolean init(java.util.Locale locale,
                           java.lang.String a_resourceBundleFilename)
Initialises the resource bundle with the specified Locale. The initialisation may be repeated with a new Locale.

Parameters:
locale - a Locale
a_resourceBundleFilename - a file name for the resource bundle; the language code for the locale will be added programmatically (e.g. _en, _de, ...).

isInitialised

public static boolean isInitialised()

getLocale

public static java.util.Locale getLocale()
Returns the Locale that is used by this class to get the messages.

Returns:
the Locale that is used by this class to get the messages

setLocale

public static void setLocale(java.util.Locale a_locale)

getString

public static java.lang.String getString(java.lang.String a_key)
Gets the localised String for a given key.

Parameters:
a_key - a key for the localised String
Returns:
the localised String

getString

public static java.lang.String getString(java.lang.String a_key,
                                         java.lang.Object[] a_arguments)
Gets the localised String for a given key. If the String contains formatting patterns, these patterns are replaced by the corresponding arguments given in an object array. For a detailed description of the formatting options please see class java.text.MessageFormat .

Parameters:
a_key - a key for the localised String
a_arguments - an object array that contains the objects that replace
Returns:
the localised String with inserted arguments
See Also:
MessageFormat

getString

public static java.lang.String getString(java.lang.String a_key,
                                         java.lang.Object a_argument)
Gets the localised String for a given key. If the String contains a formatting pattern, this pattern is replaced by the given argument object. Note that this method allows only one argument. For a detailed description of the formatting options please see class java.text.MessageFormat .

Parameters:
a_key - a key for the localised String
a_argument - a object that is inserted into the message String
Returns:
the localised String with inserted arguments
See Also:
MessageFormat