anon.util
Class LanguageMapper

java.lang.Object
  extended by anon.util.AbstractISOCodeMapper
      extended by anon.util.LanguageMapper

public class LanguageMapper
extends AbstractISOCodeMapper

Objects of this class store a language code and can translate it into the localised name of the corresponding language. The default locale of this class is bound to the locale used in JAPMessages.

Version:
ISO 639 on 27.12.05
Author:
Rolf Wendolsky
See Also:
JAPMessages, http://www.w3.org/WAI/ER/IG/ert/iso639.htm

Field Summary
private  java.util.Locale m_locale
           
private static java.lang.String[] ms_languageCodes
           
private static java.lang.String MSG_CHOOSE_LANGUAGE
           
 
Constructor Summary
LanguageMapper()
          Constructs an empty LanguageMapper object.
LanguageMapper(int a_maxTextLength)
          Constructs an empty LanguageMapper object.
LanguageMapper(java.lang.String a_ISOCode)
          Constructs a new LanguageMapper that uses the default Locale to translate its language code.
LanguageMapper(java.lang.String a_ISOCode, int a_maxTextLength)
          Constructs a new LanguageMapper that uses the default Locale to translate its language code.
LanguageMapper(java.lang.String a_ISOCode, int a_maxTextLength, java.util.Locale a_locale)
          Constructs a new LanguageMapper that uses a specific Locale to translate its language code.
LanguageMapper(java.lang.String a_ISOCode, java.util.Locale a_locale)
          Constructs a new LanguageMapper that uses a specific Locale to translate its language code.
 
Method Summary
private  void createLocale()
          Creates the internal Locale object from the language code.
protected  java.lang.String getChooseMessage()
          Returns a message that is displayed when this mapped object has an empty ISO code.
protected  java.lang.String getJRETransaltionOfISOCode(java.lang.String a_ISOLanguageCode, java.util.Locale a_locale)
           
 java.util.Locale getLocale()
          Returns a Locale object constructed from the language code.
 java.util.Locale getLocale(java.lang.String a_countryCode)
          Creates a Locale object from the language code and a given country code.
static java.util.Vector getLocalisedLanguages()
          Returns a Vector with LanguageMappers for all officially assigned language codes.
static java.util.Vector getLocalisedLanguages(int a_maxTextLength)
          Returns a Vector with LanguageMappers for all officially assigned language codes.
static java.util.Vector getLocalisedLanguages(int a_maxTextLength, java.util.Locale a_loc)
          Returns a Vector with LanguageMappers for all officially assigned language codes.
static java.util.Vector getLocalisedLanguages(java.util.Locale a_loc)
          Returns a Vector with LanguageMappers for all officially assigned language codes.
 
Methods inherited from class anon.util.AbstractISOCodeMapper
equals, getISOCode, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ms_languageCodes

private static final java.lang.String[] ms_languageCodes

MSG_CHOOSE_LANGUAGE

private static final java.lang.String MSG_CHOOSE_LANGUAGE

m_locale

private java.util.Locale m_locale
Constructor Detail

LanguageMapper

public LanguageMapper()
Constructs an empty LanguageMapper object. Its toString() method returns a message that requests to choose a valid language code. The message is defined by the default Locale.


LanguageMapper

public LanguageMapper(int a_maxTextLength)
Constructs an empty LanguageMapper object. Its toString() method returns a message that requests to choose a valid language code. The message is defined by the default Locale.

Parameters:
a_maxTextLength - the maximum length of the toString() output

LanguageMapper

public LanguageMapper(java.lang.String a_ISOCode,
                      int a_maxTextLength)
               throws java.lang.IllegalArgumentException
Constructs a new LanguageMapper that uses the default Locale to translate its language code.

Parameters:
a_ISOCode - a two-letter language code
a_maxTextLength - the maximum length of the toString() output
Throws:
java.lang.IllegalArgumentException
See Also:
getLocalisedCountries(int)

LanguageMapper

public LanguageMapper(java.lang.String a_ISOCode)
               throws java.lang.IllegalArgumentException
Constructs a new LanguageMapper that uses the default Locale to translate its language code.

Parameters:
a_ISOCode - a two-letter language code
Throws:
java.lang.IllegalArgumentException
See Also:
getLocalisedCountries(int)

LanguageMapper

public LanguageMapper(java.lang.String a_ISOCode,
                      java.util.Locale a_locale)
               throws java.lang.IllegalArgumentException
Constructs a new LanguageMapper that uses a specific Locale to translate its language code.

Parameters:
a_ISOCode - a two-letter language code
a_locale - a Locale
Throws:
java.lang.IllegalArgumentException
See Also:
getLocalisedCountries(int, Locale)

LanguageMapper

public LanguageMapper(java.lang.String a_ISOCode,
                      int a_maxTextLength,
                      java.util.Locale a_locale)
               throws java.lang.IllegalArgumentException
Constructs a new LanguageMapper that uses a specific Locale to translate its language code.

Parameters:
a_ISOCode - a two-letter language code
a_locale - a Locale
a_maxTextLength - the maximum length of the toString() output
Throws:
java.lang.IllegalArgumentException
See Also:
getLocalisedCountries(int, Locale)
Method Detail

getLocale

public java.util.Locale getLocale()
Returns a Locale object constructed from the language code.

Returns:
a Locale object constructed from the language code

getLocale

public java.util.Locale getLocale(java.lang.String a_countryCode)
Creates a Locale object from the language code and a given country code.

Parameters:
a_countryCode - an ISO country code
Returns:
a Locale object from the language code and a given country code
See Also:
CountryMapper

getLocalisedLanguages

public static java.util.Vector getLocalisedLanguages()
Returns a Vector with LanguageMappers for all officially assigned language codes. The constructed LanguageMappers use the default locale.

Returns:
a Vector with LanguageMappers for all officially assigned language codes

getLocalisedLanguages

public static java.util.Vector getLocalisedLanguages(java.util.Locale a_loc)
Returns a Vector with LanguageMappers for all officially assigned language codes. The constructed LanguageMappers use the default locale.

Parameters:
a_loc - the locale that is used in all contructed LanguageMappers
Returns:
a Vector with LanguageMappers for all officially assigned language codes

getLocalisedLanguages

public static java.util.Vector getLocalisedLanguages(int a_maxTextLength)
Returns a Vector with LanguageMappers for all officially assigned language codes. The constructed LanguageMappers use the default locale.

Parameters:
a_maxTextLength - the maximum length of the toString() output
Returns:
a Vector with LanguageMappers for all officially assigned language codes

getLocalisedLanguages

public static java.util.Vector getLocalisedLanguages(int a_maxTextLength,
                                                     java.util.Locale a_loc)
Returns a Vector with LanguageMappers for all officially assigned language codes.

Parameters:
a_loc - the locale that is used in all constructed LanguageMappers
a_maxTextLength - the maximum length of the toString() output
Returns:
a Vector with LanguageMappers for all officially assigned language codes

getChooseMessage

protected final java.lang.String getChooseMessage()
Description copied from class: AbstractISOCodeMapper
Returns a message that is displayed when this mapped object has an empty ISO code. The user is asked to choose a mapped object.

Specified by:
getChooseMessage in class AbstractISOCodeMapper
Returns:
a message that is displayed when this mapped object has an empty ISO code

getJRETransaltionOfISOCode

protected java.lang.String getJRETransaltionOfISOCode(java.lang.String a_ISOLanguageCode,
                                                      java.util.Locale a_locale)
Specified by:
getJRETransaltionOfISOCode in class AbstractISOCodeMapper

createLocale

private void createLocale()
Creates the internal Locale object from the language code.