public abstract class AbstractNlsMessage extends Object implements NlsMessage
NlsMessage
. NlsMessage
interface to gain compatibility
with further releases.Modifier and Type | Field and Description |
---|---|
static Locale |
LOCALE_ROOT
Locale.ROOT is only available since java 6.
|
private static long |
serialVersionUID |
LOCALIZATION_FAILURE_PREFIX
KEY_ANNOTATION, KEY_ARGUMENT, KEY_CAPACITY, KEY_CONTAINER, KEY_DEFAULT, KEY_DIRECTORY, KEY_ERROR, KEY_EXISTING, KEY_EXPECTED, 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_USER, KEY_VALUE
Constructor and Description |
---|
AbstractNlsMessage()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
Object |
getArgument(int index)
Deprecated.
|
int |
getArgumentCount()
This method gets the number of language independent arguments of this exception.
|
String |
getLocalizedMessage()
|
String |
getLocalizedMessage(Locale locale)
This method gets the resolved and localized message.
First it will translate the
internationalized message to the given Locale . |
void |
getLocalizedMessage(Locale locale,
Appendable buffer)
This method writes the
localized message to the given buffer . |
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() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getArgument, getInternationalizedMessage, getLocalizedMessage
private static final long serialVersionUID
public static final Locale LOCALE_ROOT
@Deprecated public Object getArgument(int index)
NlsMessage.getArgument(String)
Argument
for the given index.getArgument
in interface NlsMessage
index
- is the index of the requested argument.null
if no such argument exists.public int getArgumentCount()
NlsMessage
getArgumentCount
in interface NlsMessage
public String getLocalizedMessage()
NlsMessage
localized message
as String
using the
default Locale
. In the simplest case Locale.getDefault()
is used but if available
LocaleContextHolder
from spring is used.NlsMessage.getLocalizedMessage(Locale)
instead.getLocalizedMessage
in interface NlsMessage
public String getLocalizedMessage(Locale locale)
NlsMessage
translate
the
internationalized message
to the given Locale
. If this fails for
whatever reason, the internationalized message
is used as fallback.arguments
with their according
values
.internationalized message
is "Welcome {name}!"
and the argument
with the key @c"name"
has the value "Joelle"
. After
translation to Locale.GERMAN
the message may be "Willkommen {name}!"
. This results in the
resolved message "Willkommen Joelle!"
. If the German localization was not present or has a syntax error,
the root locale
is used as fallback result in "Welcome Joelle!"
.getLocalizedMessage
in interface NlsMessage
locale
- is the locale to translate to.net.sf.mmm.util.nls.api
public void getLocalizedMessage(Locale locale, Appendable buffer)
NlsMessage
getLocalizedMessage
in interface NlsMessage
locale
- is the locale to translate to.buffer
- is the buffer where to write the message to.NlsMessage.getLocalizedMessage(Locale)
public String getLocalizedMessage(Locale locale, NlsTemplateResolver resolver)
NlsMessage
getLocalizedMessage
in interface NlsMessage
locale
- is the locale to translate to.resolver
- is used to translate the message.NlsMessage.getLocalizedMessage(Locale, NlsTemplateResolver, Appendable)
public String getMessage()
NlsMessage
NlsMessage.getLocalizedMessage(Locale)
instead of this method.getMessage
in interface NlsMessage
NlsMessage.getLocalizedMessage(Locale, NlsTemplateResolver)
public NlsMessage toNlsMessage()
NlsObject
Object.toString()
with native language support.toNlsMessage
in interface NlsObject
Copyright © 2001–2016 mmm-Team. All rights reserved.