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

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

public abstract class BasicNlsMessage
extends AbstractNlsMessage

This is the abstract implementation of NlsMessage with the basic features.
You should extend this class whenever suitable to implement NlsMessage.

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

Field Summary
private  Map<String,Object> arguments
           
private  String message
           
private  NlsTemplate template
          The message as NlsTemplate.
 
Fields inherited from class net.sf.mmm.util.nls.base.AbstractNlsMessage
LOCALE_ROOT
 
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
BasicNlsMessage(NlsTemplate template, Map<String,Object> messageArguments)
          The constructor.
BasicNlsMessage(String internationalizedMessage, Map<String,Object> messageArguments)
          The constructor.
 
Method Summary
 Object getArgument(String key)
          This method gets the language independent argument for the given key.
protected  Map<String,Object> getArguments()
          This method gets the message arguments.
 String getInternationalizedMessage()
          This method gets the internationalized message that can be translated to a native language.
 NlsTemplate getTemplate()
          This method gets the NlsTemplate of this message.
 NlsTemplate getTemplate(NlsTemplateResolver resolver)
          This method gets the NlsTemplate of this message.
 
Methods inherited from class net.sf.mmm.util.nls.base.AbstractNlsMessage
getArgument, getArgumentCount, getLocalizedMessage, getLocalizedMessage, getLocalizedMessage, getMessage, toNlsMessage, 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
getLocalizedMessage
 

Field Detail

template

private NlsTemplate template
The message as NlsTemplate.


message

private String message
See Also:
getInternationalizedMessage()

arguments

private final Map<String,Object> arguments
See Also:
getArgument(String)
Constructor Detail

BasicNlsMessage

public BasicNlsMessage(NlsTemplate template,
                       Map<String,Object> messageArguments)
The constructor.

Parameters:
template - is the NlsTemplate for the raw message.
messageArguments - are the arguments filled into the message after nationalization.

BasicNlsMessage

public BasicNlsMessage(String internationalizedMessage,
                       Map<String,Object> messageArguments)
The constructor.

Parameters:
internationalizedMessage - is the internationalized message.
messageArguments - are the arguments filled into the message after nationalization.
Method Detail

getArgument

public Object getArgument(String key)
This method gets the language independent argument for the given key.

Parameters:
key - is the name of the requested argument.
Returns:
the argument for the given key.

getInternationalizedMessage

public String getInternationalizedMessage()
This method gets the internationalized message that can be translated to a native language. The language independent arguments are filled into the message after the translation process.
E.g. the i18n message may be "Welcome {name}!" and there is one argument that is the string "Joelle". The final result will then be "Welcome Joelle!". If the message is translated to German as "Willkommen {name}!" the final result will be "Willkommen Joelle!".

Returns:
the message for internationalization.
See Also:
NlsMessage.getArgument(String), MessageFormat

getArguments

protected Map<String,Object> getArguments()
This method gets the message arguments.

Returns:
the Map with the arguments.

getTemplate

public NlsTemplate getTemplate()
This method gets the NlsTemplate of this message.

Returns:
the text the NlsTemplate or null if NOT yet resolved.

getTemplate

public NlsTemplate getTemplate(NlsTemplateResolver resolver)
This method gets the NlsTemplate of this message.

Parameters:
resolver - is the NlsTemplateResolver used to resolve the NlsTemplate if NOT yet available.
Returns:
the text the NlsTemplate.


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