| java.lang.Object com.jcorporate.expresso.core.i18n.Messages
Messages | public class Messages extends java.lang.Object (Code) | | Messages.java
The Messages object provides a way to gain access to the appropriate
local-language version of a message, and to provide substitution of
parameters in the message string if necessary.
The appropriate local language is determined by means of the following:
Created on January 10, 2001, 8:35 AM
author: Michael Nash |
Method Summary | |
public static void | establishLocale(HttpServletRequest req) Figure out a Locale by reading the current request. | public static Locale | getDefaultLocale() | public static Locale | getLocale(HttpServletRequest req) | public static String | getString(String schemaClass, Locale l, String stringCode, Object[] args) The "full" form of getString must specify a schema, language and
country. | public static String | getString(String stringCode) | public static String | getString(String stringCode, Object[] args) Convenience method that gets a string with arguments
using the default schema (e.g. | public static String | getString(String schemaClass, String stringCode) | public static String | getString(Stack schemaStack, Locale ourLocale, String stringCode, Object[] args) | public static String | getString(String schemaClass, HttpServletRequest req, String stringCode, Object[] args) | public static String | getString(Locale l, String stringCode) | public static String | getString(Locale l, String stringCode, Object[] args) | public static String | getString(String schemaClass, Locale l, String stringCode) | public static String | getString(String schemaClass, String stringCode, Object[] args) If we have no information about what language we should be using, we
use the defaults out of the properties file if present. | public static String | getString(HttpServletRequest req, String stringCode) | public static String | getString(HttpServletRequest req, String stringCode, String firstReplace) | public String | getString(HttpServletRequest req, String stringCode, String firstReplace, String secondReplace) | public String | getString(HttpServletRequest req, String stringCode, String firstReplace, String secondReplace, String thirdReplace) | public static String | getStringByPath(String bundlePath, String language, String country, String stringCode, Object[] args) | public static String | getStringForUser(int uid, String dbName, String schemaClass, String stringCode, Object[] args) | public static String | getStringRequired(String schemaClass, Locale l, String stringCode, Object[] args) Return a string out of our message bundle associated with the specified schemaClass,
throwing an exception if it's not found
Parameters: schemaClass - the schema class Parameters: l - the Locale Parameters: stringCode - the string code Parameters: args - any arguments. | public static String | getStringRequired(String schemaClass, String stringCode) | public static String | getStringRequired(Stack schemaStack, Locale ourLocale, String stringCode, Object[] args) | public static String | getStringUnrequired(Stack schemaStack, Locale ourLocale, String stringCode, Object[] args) | public static void | setDefaultSchema(String newDefault) |
Messages | public Messages()(Code) | | Creates new Class
|
establishLocale | public static void establishLocale(HttpServletRequest req) throws ServletException(Code) | | Figure out a Locale by reading the current request.
If there is a currently logged-in user, use that users UserPreference
settings to determine the language.
If there is no logged-in user, use the browser settings if available.
If no user and no browser settings, use the context's default language.
If there is no context default setting, use english.
At the end of calling this method, the session will contain a locale
object for this user, one way or another :-)
|
getString | public static String getString(String schemaClass, Locale l, String stringCode, Object[] args)(Code) | | The "full" form of getString must specify a schema, language and
country. If we don't have one of these things, we use the convenience
methods to determine them
Parameters: schemaClass - the schema class Parameters: l - the Locale Parameters: stringCode - the string code Parameters: args - any arguments. translated string, or if not found, the stringCode |
getString | public static String getString(String stringCode)(Code) | | Convenience method to return a specified string from the default
schema, with no arguments
Parameters: stringCode - |
getString | public static String getString(String stringCode, Object[] args)(Code) | | Convenience method that gets a string with arguments
using the default schema (e.g. no specific schema specified)
but with the specified arguments
Parameters: stringCode - Parameters: args - |
getString | public static String getString(String schemaClass, String stringCode)(Code) | | get string translation
Parameters: schemaClass - name of schema Parameters: stringCode - The string code to retrieve translated string, or if not found, the stringCode |
getString | public static String getString(Stack schemaStack, Locale ourLocale, String stringCode, Object[] args)(Code) | | Convenience method that gets a string using the schemaStack, looping
through stack until the key is found
Parameters: schemaStack - A Stack of schemas Parameters: ourLocale - The specified Locale Object Parameters: stringCode - The string code to retrieve Parameters: args - the formatting arguments for the String The properly formatted string as read from the messages bundle or the key if not found |
getString | public static String getString(String schemaClass, HttpServletRequest req, String stringCode, Object[] args) throws ServletException(Code) | | Convenience method to use the current default schema
Parameters: schemaClass - Parameters: req - Parameters: stringCode - Parameters: args - translated string, or if not found, the stringCode |
getString | public static String getString(String schemaClass, Locale l, String stringCode)(Code) | | getString(schema, locale, stringCode)
translated string, or if not found, the stringCode |
getString | public static String getString(String schemaClass, String stringCode, Object[] args)(Code) | | If we have no information about what language we should be using, we
use the defaults out of the properties file if present. If there are no
defaults in the property file, we use english
Parameters: schemaClass - Parameters: stringCode - Parameters: args - translated string, or if not found, the stringCode |
getString | public String getString(HttpServletRequest req, String stringCode, String firstReplace, String secondReplace, String thirdReplace) throws ServletException(Code) | | Convenience method to return a string out of our message bundle, using the thres
string arguments as the replacement arguments
Parameters: req - Parameters: stringCode - Parameters: firstReplace - Parameters: secondReplace - Parameters: thirdReplace - |
getStringByPath | public static String getStringByPath(String bundlePath, String language, String country, String stringCode, Object[] args)(Code) | | Variation on the above gets a string from a specified message bundle
path
Parameters: bundlePath - Parameters: language - Parameters: country - Parameters: stringCode - Parameters: args - |
getStringForUser | public static String getStringForUser(int uid, String dbName, String schemaClass, String stringCode, Object[] args)(Code) | | use locale based on user ID, which is set as user preference;
use with discrimination--it may be better to get locale from request
Parameters: uid - Parameters: dbName - Parameters: schemaClass - Parameters: stringCode - Parameters: args - translated string, or if not found, the stringCode See Also: Messages.getString(java.util.Locale,String) |
getStringRequired | public static String getStringRequired(String schemaClass, Locale l, String stringCode, Object[] args) throws IllegalArgumentException(Code) | | Return a string out of our message bundle associated with the specified schemaClass,
throwing an exception if it's not found
Parameters: schemaClass - the schema class Parameters: l - the Locale Parameters: stringCode - the string code Parameters: args - any arguments. java.lang.String throws: IllegalArgumentException - if the given string code doesn't exist in the given bundle. |
getStringRequired | public static String getStringRequired(String schemaClass, String stringCode)(Code) | | Return a string out of our message bundle associated with the specified schemaClass,
throwing an exception if it's not found
Parameters: schemaClass - the schema class Parameters: stringCode - the string code java.lang.String throws: IllegalArgumentException - if the given string code doesn't exist in the given bundle. |
getStringRequired | public static String getStringRequired(Stack schemaStack, Locale ourLocale, String stringCode, Object[] args) throws IllegalArgumentException(Code) | | Convenience method that gets a string using the schemaStack, looping
through it until the key is found
Parameters: schemaStack - A Stack of schemas Parameters: ourLocale - The specified Locale Object Parameters: stringCode - The string code to retrieve Parameters: args - the formatting arguments for the String The properly formatted string as read from the messages bundle or the key if not found throws: IllegalArgumentException - if the given string code doesn't exist in any schema in stack. |
getStringUnrequired | public static String getStringUnrequired(Stack schemaStack, Locale ourLocale, String stringCode, Object[] args) throws IllegalArgumentException(Code) | | Convenience method that gets a string using the schemaStack, looping
through it until the key is found
Parameters: schemaStack - A Stack of schemas Parameters: ourLocale - The specified Locale Object Parameters: stringCode - The string code to retrieve Parameters: args - the formatting arguments for the String The properly formatted string as read from the messages bundle or the key if not found |
setDefaultSchema | public static void setDefaultSchema(String newDefault)(Code) | | Set the default schema to a class name of a Schema object
Parameters: newDefault - |
|
|