common-util

local.tomas.i18n
Class Messages

java.lang.Object
  extended by local.tomas.i18n.Messages
Direct Known Subclasses:
ExpressionMessages

public abstract class Messages
extends Object

Base class for internationalized message containers.

Author:
Teubner

Constructor Summary
protected Messages(Class<? extends Messages> messagesClass)
          Construct container from message container class.
protected Messages(String bundleName)
          Construct container from message bundle name.
 
Method Summary
 String format(Locale locale, String key, Object o1)
          Format internationalized message with a single argument.
 String format(Locale locale, String key, Object[] args)
          Format internationalized message with a list of arguments.
 String format(Locale locale, String key, Object o1, Object o2)
          Format internationalized message with two arguments.
 String format(Locale locale, String key, Object o1, Object o2, Object o3)
          Format internationalized message with three arguments.
 Locale[] getAvailableLocales()
          Get available locales for this container.
static Messages getInstance(Class<? extends Messages> msgClass)
          Get singleton instance.
 String getString(Locale locale, String key)
          Get localized string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Messages

protected Messages(String bundleName)
Construct container from message bundle name.

Parameters:
bundleName - message bundle name

Messages

protected Messages(Class<? extends Messages> messagesClass)
Construct container from message container class.

Parameters:
messagesClass - message container class
Method Detail

getInstance

public static Messages getInstance(Class<? extends Messages> msgClass)
Get singleton instance.

Parameters:
msgClass - message container class
Returns:
the instance

getString

public String getString(Locale locale,
                        String key)
Get localized string.

Parameters:
locale - locale to use
key - key of string in bundle
Returns:
localized string

format

public String format(Locale locale,
                     String key,
                     Object[] args)
Format internationalized message with a list of arguments.

Parameters:
locale - locale to use
key - key of message in bundle
args - message arguments
Returns:
formatted message

format

public String format(Locale locale,
                     String key,
                     Object o1)
Format internationalized message with a single argument.

Parameters:
locale - locale to use
key - key of message in bundle
o1 - message argument
Returns:
formatted message

format

public String format(Locale locale,
                     String key,
                     Object o1,
                     Object o2)
Format internationalized message with two arguments.

Parameters:
locale - locale to use
key - key of message in bundle
o1 - first message argument
o2 - second message argument
Returns:
formatted message

format

public String format(Locale locale,
                     String key,
                     Object o1,
                     Object o2,
                     Object o3)
Format internationalized message with three arguments.

Parameters:
locale - locale to use
key - key of message in bundle
o1 - first message argument
o2 - second message argument
o3 - third message argument
Returns:
formatted message

getAvailableLocales

public Locale[] getAvailableLocales()
Get available locales for this container.

Returns:
all locales.

common-util

Copyright © 2005-2007 Tomas Teubner. All Rights Reserved.