org.mailster.gui
Class Messages

java.lang.Object
  extended by org.mailster.gui.Messages

public class Messages
extends java.lang.Object

---
Mailster (C) 2007-2009 De Oliveira Edouard

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

See  Mailster Web Site
---

Messages.java - Handles localisation of UI.

Version:
$Revision: 1.6 $, $Date: 2008/12/06 13:57:17 $
Author:
Edouard De Oliveira

Field Summary
private static java.util.ResourceBundle bundle
          The resource bundle.
private static java.lang.String DEFAULT_RESOURCE_BASE
          The default base name of the language resources, a fully qualified class name.
private static java.util.ResourceBundle defaultBundle
          The default resource bundle is the one corresponding to local Locale.
private static java.util.TreeMap<java.lang.String,LanguageResource> LANGUAGE_RESOURCES
          Stores the single LanguageResource objects in a sorted TreeMap data structure
private static java.util.Locale locale
          The current locale.
private static org.slf4j.Logger log
           
 
Constructor Summary
private Messages()
           
 
Method Summary
static LanguageResource[] getAvailableLanguageResources()
          Gets all available LanguageResources
static LanguageResource getLanguageResource(java.lang.String language)
          Gets the LanguageResource mapped to the specified ISO 639 two letter language code (e.g.
static java.util.Locale getLocale()
           
static java.lang.String getString(java.lang.String key)
          Loads a string from the resource bundle file.
static java.lang.String getString(java.lang.String key, java.lang.String defaultValue)
          Loads a string from the resource bundle file.
static void setLocale(java.util.Locale l)
          NOTE : Will not reload the already loaded strings.
private static void setupResourceBundle()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final org.slf4j.Logger log

DEFAULT_RESOURCE_BASE

private static final java.lang.String DEFAULT_RESOURCE_BASE
The default base name of the language resources, a fully qualified class name.

See Also:
Constant Field Values

LANGUAGE_RESOURCES

private static final java.util.TreeMap<java.lang.String,LanguageResource> LANGUAGE_RESOURCES
Stores the single LanguageResource objects in a sorted TreeMap data structure


locale

private static java.util.Locale locale
The current locale. Defaults to Locale.ENGLISH.


defaultBundle

private static java.util.ResourceBundle defaultBundle
The default resource bundle is the one corresponding to local Locale.


bundle

private static java.util.ResourceBundle bundle
The resource bundle.

Constructor Detail

Messages

private Messages()
Method Detail

setupResourceBundle

private static void setupResourceBundle()

getAvailableLanguageResources

public static LanguageResource[] getAvailableLanguageResources()
Gets all available LanguageResources

Returns:
an array of LanguageResource objects holding all available resources

getLanguageResource

public static LanguageResource getLanguageResource(java.lang.String language)
Gets the LanguageResource mapped to the specified ISO 639 two letter language code (e.g. "de" for german, "en" for english)

Parameters:
language - the ISO 639 twoe letter language code for which to get the mapped LanguageResource
Returns:
the LanguageResource mapped to the specified ISO 639 two letter language code (e.g. "de" for german, "en" for english); null if no such LanguageResource is available for the specified language

getString

public static java.lang.String getString(java.lang.String key)
Loads a string from the resource bundle file. If not found or empty, try to load the string from the default bundle then returns the key between square brackets.

Parameters:
key - the key to load the message string
Returns:
the string or the key if string wasn't found

getString

public static java.lang.String getString(java.lang.String key,
                                         java.lang.String defaultValue)
Loads a string from the resource bundle file. If not found or empty, returns the defaultValue.

Parameters:
key - the key to load the message string
defaultValue - the value to return if not found or empty
Returns:
the string or the key if string wasn't found

getLocale

public static java.util.Locale getLocale()

setLocale

public static void setLocale(java.util.Locale l)
NOTE : Will not reload the already loaded strings.