org.clazzes.util.aop.i18n.impl
Class MessagesImpl

java.lang.Object
  extended by org.clazzes.util.aop.i18n.impl.MessagesImpl
All Implemented Interfaces:
Messages

public class MessagesImpl
extends Object
implements Messages

The implementation of our Messages interface.


Constructor Summary
MessagesImpl(Locale locale, PluralRule pluralRule, ResourceBundle resources)
           
 
Method Summary
 String formatPluralString(double n, String key, Object... args)
          Format the given localized message with possible plural forms with a set of arguments.
 String formatString(String key, Object... args)
          Format the given localized message with a set of arguments.
 Locale getLocale()
           
 PluralRule getPluralRule()
           
 String getPluralString(double n, String key)
          Find a localized message with possible plural forms.
 String getString(String key)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessagesImpl

public MessagesImpl(Locale locale,
                    PluralRule pluralRule,
                    ResourceBundle resources)
Method Detail

getLocale

public Locale getLocale()
Specified by:
getLocale in interface Messages
Returns:
The underlying locale.

getPluralRule

public PluralRule getPluralRule()
Specified by:
getPluralRule in interface Messages
Returns:
The underlying plural rule.

getString

public String getString(String key)
Specified by:
getString in interface Messages
Parameters:
key - The key to search for in the message catalog.
Returns:
The localized message.

formatString

public String formatString(String key,
                           Object... args)
Description copied from interface: Messages
Format the given localized message with a set of arguments. A shortcut for
 String.format(i18n.getLocale(),i18n.getString(key),args)
 

Specified by:
formatString in interface Messages
Parameters:
key - The key to search for in the message catalog.
args - The argument to the format string.
Returns:
The formatted localized message.

getPluralString

public String getPluralString(double n,
                              String key)
Description copied from interface: Messages
Find a localized message with possible plural forms. This method searches for the key <key>.<tag>, if the associated PluralRule return a non-null plural tag like one or zero. If a message for these special keys is not found or the plural rule return NullPointerException, the unmodified key is used to fetch the message.

Specified by:
getPluralString in interface Messages
Parameters:
n - The plural denominator.
key - The key to search for in the message catalog.
Returns:
The localized message.

formatPluralString

public String formatPluralString(double n,
                                 String key,
                                 Object... args)
Description copied from interface: Messages
Format the given localized message with possible plural forms with a set of arguments. A shortcut for
 String.format(i18n.getLocale(),i18n.getPluralString(n,key),args)
 

Specified by:
formatPluralString in interface Messages
Parameters:
n - The plural denominator.
key - The key to search for in the message catalog.
args - The argument to the format string.
Returns:
The formatted localized message.


Copyright © 2012. All Rights Reserved.