Expresso 5-6

com.jcorporate.expresso.core.i18n
Class MessageBundle

java.lang.Object
  extended bycom.jcorporate.expresso.core.i18n.MessageBundle

public class MessageBundle
extends Object

A message bundle handles the messages for a specific combination of language, country and schema Created on January 21, 2001, 8:43 PM


Field Summary
static String DEFAULT_BUNDLE_NAME
          The default bundle name
static String DEFAULT_BUNDLE_PATH
           
 
Constructor Summary
MessageBundle()
          Creates new Class
 
Method Summary
 String getBundleName()
          Gets the resource bundle name author: Peter Pilgrim, Sun Sep 07 12:16:56 BST 2003
 String getBundlePath()
          Returns the location of the Messages bundle path as specified by your schema.
 String getCountry()
          Used to get the sub-language country code
 String getLanguage()
           
protected  Schema getSchema(String schemaClass)
          Instantiate & return the schema class given in the current parameter
 String getString(String stringCode, Object[] args)
          Formats the string code with the appropriate argument array.
protected  String getStringFromBundle(Locale ourLocale, String stringCode)
          Return a string for a specific locale
protected  String getStringFromDefaultSchemaBundle(Locale ourLocale, String stringCode)
          Return a string for a specific locale, using the default (expresso) schema
 String getStringOrNull(String stringCode, Object[] args)
          Formats the string code with the appropriate argument array.
 String getStringRequired(String stringCode, Object[] args)
          Formats the string code with the appropriate argument array, throwing an exception if the key does not exist.
 void setBundleName(String bundleName)
          Sets the resource bundle name
 void setBundlePath(String newBundlePath)
          Sets the path for the bundle for the specified schema
 void setCountry(String newCountry)
          Sets the country for the bundle
 void setLanguage(String newLanguage)
          Sets the language to get the Messages for
 void setSchema(String schemaName)
          Sets the schema so you can get messages from your own apps messages bundle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_BUNDLE_NAME

public static final String DEFAULT_BUNDLE_NAME
The default bundle name

See Also:
Constant Field Values

DEFAULT_BUNDLE_PATH

public static final String DEFAULT_BUNDLE_PATH
See Also:
Constant Field Values
Constructor Detail

MessageBundle

public MessageBundle()
Creates new Class

Method Detail

setBundleName

public void setBundleName(String bundleName)
Sets the resource bundle name

Parameters:
bundleName - The bundle name to use when retrieving messages

getBundleName

public String getBundleName()
Gets the resource bundle name author: Peter Pilgrim, Sun Sep 07 12:16:56 BST 2003

Returns:
java.lang.String the bundle name

setBundlePath

public void setBundlePath(String newBundlePath)
Sets the path for the bundle for the specified schema

Parameters:
newBundlePath - the bundle path

getBundlePath

public String getBundlePath()
Returns the location of the Messages bundle path as specified by your schema.

Returns:
java.lang.String

setCountry

public void setCountry(String newCountry)
Sets the country for the bundle

Parameters:
newCountry - the new two digit country code

getCountry

public String getCountry()
Used to get the sub-language country code

Returns:
the ISO two letter country code.

setLanguage

public void setLanguage(String newLanguage)
Sets the language to get the Messages for

Parameters:
newLanguage - the new language code

getLanguage

public String getLanguage()
Returns:
the language code as a java.lang.String

setSchema

public void setSchema(String schemaName)
Sets the schema so you can get messages from your own apps messages bundle

Parameters:
schemaName - The name of the schema to get the messages from

getString

public String getString(String stringCode,
                        Object[] args)
Formats the string code with the appropriate argument array. Issues warning log if code is not found.

Parameters:
stringCode - The string code to retrieve
args - the formatting arguments for the String
Returns:
The properly formatted string as read from the messages bundle, or the stringCode if not found
See Also:
MessageFormat

getStringRequired

public String getStringRequired(String stringCode,
                                Object[] args)
                         throws IllegalArgumentException
Formats the string code with the appropriate argument array, throwing an exception if the key does not exist.

Parameters:
stringCode - The string code to retrieve
args - the formatting arguments for the String
Returns:
The properly formatted string as read from the messages bundle
Throws:
IllegalArgumentException - if the given string code doesn't exist in the given bundle.
See Also:
MessageFormat

getSchema

protected Schema getSchema(String schemaClass)
Instantiate & return the schema class given in the current parameter

Parameters:
schemaClass - The instantiated schema factory
Returns:
A Schema object instantiated from the class named by the 'SchemaClass' parameter
Throws:
IllegalArgumentException - if schema class cannot be instantiated

getStringFromBundle

protected String getStringFromBundle(Locale ourLocale,
                                     String stringCode)
Return a string for a specific locale

Parameters:
ourLocale - The specified Locale Object
stringCode - The specified String code
Returns:
The properly formatted string as read from the messages bundle; never null--will throw runtime exception if not found

getStringFromDefaultSchemaBundle

protected String getStringFromDefaultSchemaBundle(Locale ourLocale,
                                                  String stringCode)
Return a string for a specific locale, using the default (expresso) schema

Parameters:
ourLocale - The specified Locale Object
stringCode - The specified String code
Returns:
The properly formatted string as read from the messages bundle

getStringOrNull

public String getStringOrNull(String stringCode,
                              Object[] args)
Formats the string code with the appropriate argument array. Does NOT issue warning log if code is not found, but rather returns null

Parameters:
stringCode - The string code to retrieve
args - the formatting arguments for the String
Returns:
The properly formatted string as read from the messages bundle, or null if not found
See Also:
MessageFormat

Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.