net.sf.mmm.util.nls.base
Class AbstractNlsMessage

java.lang.Object
  extended by net.sf.mmm.util.nls.base.AbstractNlsMessage
All Implemented Interfaces:
NlsMessage, NlsObject
Direct Known Subclasses:
BasicNlsMessage, ComposedNlsMessage

public abstract class AbstractNlsMessage
extends Object
implements NlsMessage

This is the abstract base implementation of NlsMessage.
You should extend this class rather than directly implementing the NlsMessage interface to gain compatibility with further releases.

Since:
2.0.1
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)

Field Summary
protected static Locale LOCALE_ROOT
          Locale.ROOT is only available since java 6.
 
Fields inherited from interface net.sf.mmm.util.nls.api.NlsMessage
LOCALIZATION_FAILURE_PREFIX
 
Fields inherited from interface net.sf.mmm.util.nls.api.NlsObject
KEY_ANNOTATION, KEY_ARGUMENT, KEY_CAPACITY, KEY_DEFAULT, KEY_DIRECTORY, KEY_ERROR, KEY_FILE, KEY_FUNCTION, KEY_ID, KEY_KEY, KEY_LOCATION, KEY_MAX, KEY_MIN, KEY_MODE, KEY_NAME, KEY_OBJECT, KEY_OPERAND, KEY_OPERATION, KEY_OPTION, KEY_PATH, KEY_PROPERTY, KEY_QUERY, KEY_RESOURCE, KEY_SIZE, KEY_SOURCE, KEY_TARGET_TYPE, KEY_TITLE, KEY_TYPE, KEY_URI, KEY_VALUE
 
Constructor Summary
AbstractNlsMessage()
          The constructor.
 
Method Summary
 Object getArgument(int index)
          Deprecated. use NlsMessage.getArgument(String)
 int getArgumentCount()
          This method gets the number of language independent arguments of this exception.
 String getLocalizedMessage()
          This method tries to get the localized message as string.
 String getLocalizedMessage(Locale locale)
          This method tries to get the localized message as string.
 String getLocalizedMessage(Locale locale, NlsTemplateResolver resolver)
          This method gets the localized message as string.
 String getMessage()
          This method gets the untranslated message (default language should be English) with arguments filled in.
 NlsMessage toNlsMessage()
          This method is the equivalent to Object.toString() with native language support.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.mmm.util.nls.api.NlsMessage
getArgument, getInternationalizedMessage, getLocalizedMessage
 

Field Detail

LOCALE_ROOT

protected static final Locale LOCALE_ROOT
Locale.ROOT is only available since java 6.

Constructor Detail

AbstractNlsMessage

public AbstractNlsMessage()
The constructor.

Method Detail

getArgument

@Deprecated
public Object getArgument(int index)
Deprecated. use NlsMessage.getArgument(String)

This method gets the Argument for the given index.

Specified by:
getArgument in interface NlsMessage
Parameters:
index - is the index of the requested argument.
Returns:
the argument at the given index or null if no such argument exists.

getArgumentCount

public int getArgumentCount()
This method gets the number of language independent arguments of this exception.

Specified by:
getArgumentCount in interface NlsMessage
Returns:
the argument count.

getLocalizedMessage

public String getLocalizedMessage()
This method tries to get the localized message as string. Since no translator is specified, the implementation may try its best to do the translation on its own according to the callers locale. Therefore this method has to do some magic behind the scenes. This may only work if you follow specific rules of the implementation of this interface. If this fails or is NOT supported, the untranslated message should be used.
ATTENTION:
If possible try to avoid using this method and use NlsMessage.getLocalizedMessage(Locale, NlsTemplateResolver) instead.

Specified by:
getLocalizedMessage in interface NlsMessage
Returns:
the localized message.

getLocalizedMessage

public String getLocalizedMessage(Locale locale)
This method tries to get the localized message as string. Since no translator is specified, the implementation may try its best to do the translation on its own according to the callers locale. Therefore this method has to do some magic behind the scenes. This may only work if you follow specific rules of the implementation of this interface. If this fails or is NOT supported, the untranslated message should be used.
ATTENTION:
If possible try to avoid using this method and use NlsMessage.getLocalizedMessage(Locale, NlsTemplateResolver) instead.

Specified by:
getLocalizedMessage in interface NlsMessage
Parameters:
locale - is the locale to translate to.
Returns:
the localized message.

getLocalizedMessage

public String getLocalizedMessage(Locale locale,
                                  NlsTemplateResolver resolver)
This method gets the localized message as string.

Specified by:
getLocalizedMessage in interface NlsMessage
Parameters:
locale - is the locale to translate to.
resolver - is used to translate the message.
Returns:
the localized message.
See Also:
NlsMessage.getLocalizedMessage(Locale, NlsTemplateResolver, Appendable)

getMessage

public String getMessage()
This method gets the untranslated message (default language should be English) with arguments filled in.

Specified by:
getMessage in interface NlsMessage
Returns:
the i18n message with arguments filled in.
See Also:
NlsMessage.getLocalizedMessage(Locale, NlsTemplateResolver)

toNlsMessage

public NlsMessage toNlsMessage()
This method is the equivalent to Object.toString() with native language support.

Specified by:
toNlsMessage in interface NlsObject
Returns:
an nls message representing this object.

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2001-2010 mmm-Team. All Rights Reserved.