org.apache.commons.i18n
Class LocalizedBundle

java.lang.Object
  extended by org.apache.commons.i18n.LocalizedBundle
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
TextBundle

public class LocalizedBundle
extends java.lang.Object
implements java.io.Serializable

The LocalizedBundle class represents a bundle of localized messages that belong together.

The LocalizedBundle class itself contains the message id and the arguments that might be used to include dynamic values into the message text. The message id specifies the base name of the message bundle. Single entries of the message bundle can be retrieved using the getText() method by passing the key of the desired message entry.

This class should not be used directly in order to retrieve entries of a message bundle. It is recommended to subclass the LocalizedBundle class in order to define a specific localized bundle.

See Also:
org.apache.commons.i18n.bundles.TextBundle, MessageBundle, ErrorBundle, Serialized Form

Field Summary
protected  java.lang.Object[] arguments
           
protected  java.lang.String id
           
static java.lang.String ID
           
protected  java.lang.String providerId
           
 
Constructor Summary
LocalizedBundle(java.lang.String messageId)
           
LocalizedBundle(java.lang.String messageId, java.lang.Object[] arguments)
           
LocalizedBundle(java.lang.String providerId, java.lang.String messageId)
           
LocalizedBundle(java.lang.String providerId, java.lang.String messageId, java.lang.Object[] arguments)
           
 
Method Summary
 java.lang.Object[] getArguments()
           
 java.lang.String getEntry(java.lang.String key, java.util.Locale locale)
           
 java.lang.String getEntry(java.lang.String key, java.util.Locale locale, java.lang.String defaultText)
           
 java.lang.String getId()
           
 java.lang.String getProviderId()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID

public static final java.lang.String ID
See Also:
Constant Field Values

providerId

protected java.lang.String providerId

id

protected java.lang.String id

arguments

protected java.lang.Object[] arguments
Constructor Detail

LocalizedBundle

public LocalizedBundle(java.lang.String providerId,
                       java.lang.String messageId)
Parameters:
providerId - The name of the message provider (i.e. source) to use for the message
messageId - The messageId refers the corresponding bundle in the file containing the localized messages.

LocalizedBundle

public LocalizedBundle(java.lang.String messageId)
Parameters:
messageId - The messageId refers the corresponding bundle in the file containing the localized messages.

LocalizedBundle

public LocalizedBundle(java.lang.String messageId,
                       java.lang.Object[] arguments)
Parameters:
messageId - The messageId refers the corresponding bundle in the file containing the localized messages.
arguments - An array of objects containing arguments for the messages. These arguments are used to insert dynamic values into the localized messages.

LocalizedBundle

public LocalizedBundle(java.lang.String providerId,
                       java.lang.String messageId,
                       java.lang.Object[] arguments)
Parameters:
providerId - The name of the message provider (i.e. source) to use for the message
messageId - The messageId refers the corresponding bundle in the file containing the localized messages.
arguments - An array of objects containing arguments for the messages. These arguments are used to insert dynamic values into the localized messages.
Method Detail

getId

public java.lang.String getId()
Returns:
returns the id of this bundle

getArguments

public java.lang.Object[] getArguments()
Returns:
returns the arguments associated with this message bundle

getProviderId

public java.lang.String getProviderId()
Returns:
The name of the message provider (i.e. source) to use for the message

getEntry

public java.lang.String getEntry(java.lang.String key,
                                 java.util.Locale locale)
                          throws MessageNotFoundException
Parameters:
key - the key of the specific message entry in the message bundle
locale - the locale for that this message should be rendered
Returns:
returns the text of the desired message entry for the given locale
Throws:
MessageNotFoundException - if an entry with the given key can not be found in this bundle

getEntry

public java.lang.String getEntry(java.lang.String key,
                                 java.util.Locale locale,
                                 java.lang.String defaultText)
Parameters:
key - the key of the specific message entry in the message bundle
locale - the locale for that this message should be rendered
defaultText - the text to be returned if no entry was found for the given key
Returns:
returns the text of the desired message entry for the given locale


Copyright 2004-2008 The Apache Software Foundation. All Rights Reserved.