public class NlsMessagePlain extends Object implements NlsMessage
NlsMessage
that only returns the message
given at
construction
and never has any arguments
.Modifier and Type | Field and Description |
---|---|
private String |
message |
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
Modifier | Constructor and Description |
---|---|
protected |
NlsMessagePlain()
The constructor for de-serialization in GWT.
|
|
NlsMessagePlain(String message)
The constructor.
|
Modifier and Type | Method and Description |
---|---|
Object |
getArgument(int index)
Deprecated.
|
Object |
getArgument(String key)
This method gets the language independent argument value for the given
key . |
int |
getArgumentCount()
Deprecated.
|
String |
getInternationalizedMessage()
This method gets the internationalized message what is the actual message template for the
root
locale without resolving its NlsArgument s. |
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.
|
void |
getLocalizedMessage(Locale locale,
NlsTemplateResolver resolver,
Appendable buffer)
This method writes the localized message to the given
buffer . |
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() |
private static final long serialVersionUID
private String message
protected NlsMessagePlain()
public NlsMessagePlain(String message)
message
- is the plain message to return for any locale without modification.public NlsMessage toNlsMessage()
NlsObject
Object.toString()
with native language support.toNlsMessage
in interface NlsObject
public String getInternationalizedMessage()
NlsMessage
root
locale
without resolving its NlsArgument
s.getInternationalizedMessage
in interface NlsMessage
"Welcome {name}!"
).NlsMessage
,
NlsMessage.getArgument(String)
,
MessageFormat
@Deprecated public int getArgumentCount()
NlsMessage
getArgumentCount
in interface NlsMessage
public Object getArgument(String key)
NlsMessage
key
.getArgument
in interface NlsMessage
key
- is the name of the requested argument.null
if NOT defined.NlsArgument
@Deprecated public Object getArgument(int index)
NlsMessage
index
.getArgument
in interface NlsMessage
index
- is the index of the requested argument.public String getMessage()
NlsMessage
NlsMessage.getLocalizedMessage(Locale)
instead of this method.getMessage
in interface NlsMessage
NlsMessage.getLocalizedMessage(Locale, NlsTemplateResolver)
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 void getLocalizedMessage(Locale locale, NlsTemplateResolver resolver, Appendable buffer)
NlsMessage
buffer
. template
that is provided via the given resolver
.
If this fails, the original message
will be used. After translation is done,
the language independent arguments will be filled in the translated message string according to the given
locale
.getLocalizedMessage
in interface NlsMessage
locale
- is the locale to translate to.resolver
- is used to resolve the template required to translate the internationalized message
.buffer
- is the buffer where to write the message to.Copyright © 2001–2016 mmm-Team. All rights reserved.