anon.util
Class AbstractISOCodeMapper

java.lang.Object
  extended by anon.util.AbstractISOCodeMapper
Direct Known Subclasses:
CountryMapper, LanguageMapper

public abstract class AbstractISOCodeMapper
extends java.lang.Object

Objects of this class store an ISO two-letter code and can translate it into a localised name.

Author:
Kuno G. Gruen, Rolf Wendolsky

Field Summary
private  boolean m_bUseDefaultLocale
           
private  java.lang.String m_iso2
           
private  java.util.Locale m_locale
           
private  int MAX_LENGTH
           
 
Constructor Summary
AbstractISOCodeMapper()
          Constructs an empty mapper object.
AbstractISOCodeMapper(int a_maxTextLength)
          Constructs an empty mapper object.
AbstractISOCodeMapper(java.lang.String a_ISOCode)
          Constructs a new mapper object that uses the default Locale to translate its ISO code.
AbstractISOCodeMapper(java.lang.String a_ISOCode, int a_maxTextLength)
          Constructs a new mapper that uses the default Locale to translate its ISO code.
AbstractISOCodeMapper(java.lang.String a_ISOCode, int a_maxTextLength, java.util.Locale a_locale)
          Constructs a new mapper object that uses a specific Locale to translate its ISO code.
AbstractISOCodeMapper(java.lang.String a_ISOCode, java.util.Locale a_locale)
          Constructs a new mapper object that uses a specific Locale to translate its ISO code.
 
Method Summary
 boolean equals(java.lang.Object a_object)
          Returns if the ISO codes of two mapper objects are equal.
protected abstract  java.lang.String getChooseMessage()
          Returns a message that is displayed when this mapped object has an empty ISO code.
 java.lang.String getISOCode()
          Returns the ISO country code stored in this CountryMapper object.
protected abstract  java.lang.String getJRETransaltionOfISOCode(java.lang.String a_ISOCode, java.util.Locale a_locale)
           
 int hashCode()
          Returns the hash code of the ISO country code.
 java.lang.String toString()
          Returns the localised name of the ISO country code of this CountryMapper object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_LENGTH

private final int MAX_LENGTH

m_bUseDefaultLocale

private boolean m_bUseDefaultLocale

m_iso2

private java.lang.String m_iso2

m_locale

private java.util.Locale m_locale
Constructor Detail

AbstractISOCodeMapper

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


AbstractISOCodeMapper

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

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

AbstractISOCodeMapper

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

Parameters:
a_ISOCode - a two-letter ISO code
a_maxTextLength - the maximum length of the toString() output
Throws:
java.lang.IllegalArgumentException - if the ISO code does not have two characters

AbstractISOCodeMapper

public AbstractISOCodeMapper(java.lang.String a_ISOCode)
                      throws java.lang.IllegalArgumentException
Constructs a new mapper object that uses the default Locale to translate its ISO code.

Parameters:
a_ISOCode - a two-letter ISO code
Throws:
java.lang.IllegalArgumentException - if the ISO code does not have two characters

AbstractISOCodeMapper

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

Parameters:
a_ISOCode - a two-letter ISO code
a_locale - a Locale
Throws:
java.lang.IllegalArgumentException - if the ISO code does not have two characters

AbstractISOCodeMapper

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

Parameters:
a_ISOCode - a two-letter ISO code
a_locale - a Locale
a_maxTextLength - the maximum length of the toString() output
Throws:
java.lang.IllegalArgumentException - if the ISO code does not have two characters
Method Detail

getISOCode

public final java.lang.String getISOCode()
Returns the ISO country code stored in this CountryMapper object. The country code may be an empty String of the length zero or a valid two-letter country code.

Returns:
the ISO country code stored in this CountryMapper object

equals

public final boolean equals(java.lang.Object a_object)
Returns if the ISO codes of two mapper objects are equal.

Overrides:
equals in class java.lang.Object
Parameters:
a_object - an Object
Returns:
true if the ISO country codes of two mapper objects are equal; false otherwise

hashCode

public final int hashCode()
Returns the hash code of the ISO country code.

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code of the ISO country code

getChooseMessage

protected abstract java.lang.String getChooseMessage()
Returns a message that is displayed when this mapped object has an empty ISO code. The user is asked to choose a mapped object.

Returns:
a message that is displayed when this mapped object has an empty ISO code

getJRETransaltionOfISOCode

protected abstract java.lang.String getJRETransaltionOfISOCode(java.lang.String a_ISOCode,
                                                               java.util.Locale a_locale)

toString

public final java.lang.String toString()
Returns the localised name of the ISO country code of this CountryMapper object. The output may depend on the current locale or on the locale that may be defined in the constructor.

Overrides:
toString in class java.lang.Object
Returns:
the localised name of the ISO country code