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

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

public class ComposedNlsMessage
extends AbstractNlsMessage

This is an implementation of NlsMessage for composing other objects or messages.

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

Field Summary
private  Object[] arguments
           
 
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
ComposedNlsMessage(Object[] arguments)
          The constructor.
 
Method Summary
 Object getArgument(int index)
          This method gets the Argument for the given index.
 Object getArgument(String key)
          This method gets the language independent argument for the given key.
 int getArgumentCount()
          This method gets the number of language independent arguments of this exception.
 String getInternationalizedMessage()
          This method gets the internationalized message that can be translated to a native language.
 void getLocalizedMessage(Locale locale, NlsTemplateResolver resolver, Appendable buffer)
          This method writes the localized message to the given buffer.
 
Methods inherited from class net.sf.mmm.util.nls.base.AbstractNlsMessage
getLocalizedMessage, getLocalizedMessage, getLocalizedMessage, getMessage, toNlsMessage, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

arguments

private Object[] arguments
See Also:
getArgument(int)
Constructor Detail

ComposedNlsMessage

public ComposedNlsMessage(Object[] arguments)
The constructor.

Parameters:
arguments - are the arguments.
Method Detail

getArgument

public Object getArgument(int index)
This method gets the Argument for the given index.

Specified by:
getArgument in interface NlsMessage
Overrides:
getArgument in class AbstractNlsMessage
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
Overrides:
getArgumentCount in class AbstractNlsMessage
Returns:
the argument count.

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

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.

getLocalizedMessage

public void getLocalizedMessage(Locale locale,
                                NlsTemplateResolver resolver,
                                Appendable buffer)
                         throws RuntimeIoException
This method writes the localized message to the given buffer.
The actual localization is done by a 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.

Parameters:
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.
Throws:
RuntimeIoException - if the given buffer produced an IOException.


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