com.arsdigita.globalization
Class Globalization

java.lang.Object
  extended bycom.arsdigita.globalization.Globalization

public class Globalization
extends Object

Utilities for the globalization process. The methods in this class make use of the assumption that the ACS handles all locale and resource negotiation so that the application developer doesn't have to worry about it.

Version:
$Revision: #14 $ $Date: 2004/04/29 $

Field Summary
static String DEFAULT_ENCODING
          The default encoding for request/response body data, as specified by the servlet spec
static String DEFAULT_PARAM_ENCODING
          The default encoding for parameterts, as specified by the servlet spec
static String ENCODING_PARAM_NAME
           
static String versionId
           
 
Constructor Summary
Globalization()
           
 
Method Summary
static String decodeParameter(javax.servlet.http.HttpServletRequest r, String name)
           Decode the value of an HttpServletRequest parameter.
static String[] decodeParameters(javax.servlet.http.HttpServletRequest r, String name)
           Decode all of the values of an HttpServletRequest array parameter.
static ResourceBundle getBundleNoFallback(String targetBundle, Locale locale, Locale defaultLocale)
           Find the ResourceBundle for this language without falling back to a default ResourceBundle in another language
static String getDefaultCharset()
          Get the default character set for encoding data
static String getDefaultCharset(javax.servlet.http.HttpServletRequest req)
          Get the default character set for the request.
static String getDefaultCharset(Locale locale)
           Get the default character set for a given locale.
static Object getLocalizedObject(javax.servlet.http.HttpServletRequest r, String key)
           Get an Object from the appropriate ResourceBundle based on the appropriate Locale and key.
static String getLocalizedString(javax.servlet.http.HttpServletRequest r, String key)
           Get a String from the appropriate ResourceBundle based on the appropriate Locale and key.
static String getLocalizedString(javax.servlet.http.HttpServletRequest r, String key, Object[] arguments)
           Get a parameterized String (for doing MessageFormatting) from the appropraite ResourceBundle based on the appropriate Locale and key.
static ResourceBundle getResourceBundle()
           Get the appropriate ResourceBundle based ont he request and locale.
static ResourceBundle getResourceBundle(javax.servlet.http.HttpServletRequest r)
           Get the appropriate ResourceBundle based on the request and Locale
static void loadLocaleToCharsetMap()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values

ENCODING_PARAM_NAME

public static final String ENCODING_PARAM_NAME
See Also:
Constant Field Values

DEFAULT_PARAM_ENCODING

public static final String DEFAULT_PARAM_ENCODING
The default encoding for parameterts, as specified by the servlet spec

See Also:
Constant Field Values

DEFAULT_ENCODING

public static final String DEFAULT_ENCODING
The default encoding for request/response body data, as specified by the servlet spec

See Also:
Constant Field Values
Constructor Detail

Globalization

public Globalization()
Method Detail

loadLocaleToCharsetMap

public static void loadLocaleToCharsetMap()

getDefaultCharset

public static String getDefaultCharset()
Get the default character set for encoding data

Returns:
String the character set

getDefaultCharset

public static String getDefaultCharset(Locale locale)

Get the default character set for a given locale.

Parameters:
locale -
Returns:
String the character set
See Also:
Locale

getDefaultCharset

public static String getDefaultCharset(javax.servlet.http.HttpServletRequest req)
Get the default character set for the request. First tries the getCharacterENcoding() method, then falls back on the DEFAULT_PARAM_ENCODING

Returns:
String the character set

decodeParameter

public static final String decodeParameter(javax.servlet.http.HttpServletRequest r,
                                           String name)

Decode the value of an HttpServletRequest parameter. The value is decoded appropriately (lets hope so anyway).

Parameters:
r - The HttpServletRequest for which to get the value.
name - The name of the parameter to retrieve.
Returns:
String The decoded value of the parameter.

decodeParameters

public static final String[] decodeParameters(javax.servlet.http.HttpServletRequest r,
                                              String name)

Decode all of the values of an HttpServletRequest array parameter.

Parameters:
r - The HttpServletRequest for which to decode the parameters.
Returns:
String[] The decoded parameters.

getResourceBundle

public static ResourceBundle getResourceBundle()

Get the appropriate ResourceBundle based ont he request and locale.

Returns:
ResourceBundle
See Also:
ResourceBundle

getResourceBundle

public static ResourceBundle getResourceBundle(javax.servlet.http.HttpServletRequest r)

Get the appropriate ResourceBundle based on the request and Locale

Parameters:
r - The current HttpServletRequest
Returns:
ResourceBundle
See Also:
ResourceBundle

getLocalizedObject

public static Object getLocalizedObject(javax.servlet.http.HttpServletRequest r,
                                        String key)

Get an Object from the appropriate ResourceBundle based on the appropriate Locale and key.

Parameters:
r - The current HttpServletRequest.
key - The key used to select the appropriate Object
Returns:
The localized Object
See Also:
ResourceBundle

getLocalizedString

public static String getLocalizedString(javax.servlet.http.HttpServletRequest r,
                                        String key)

Get a String from the appropriate ResourceBundle based on the appropriate Locale and key.

Parameters:
r - The current HttpServletRequest.
key - The key used to select the appropriate String
Returns:
The localized String
See Also:
ResourceBundle

getLocalizedString

public static String getLocalizedString(javax.servlet.http.HttpServletRequest r,
                                        String key,
                                        Object[] arguments)

Get a parameterized String (for doing MessageFormatting) from the appropraite ResourceBundle based on the appropriate Locale and key. Then interpolate the values for the other keys passed.

Parameters:
r - The current HttpServletRequest.
key - The key used to select the appropriate String
arguments - A Object[] containing the other keys to localize and interpolate into the parameterized string. It may also contain other Objects beside Strings, such as Date objects and Integers, etc.
Returns:
The localized and interpolated String
See Also:
MessageFormat, ResourceBundle

getBundleNoFallback

public static ResourceBundle getBundleNoFallback(String targetBundle,
                                                 Locale locale,
                                                 Locale defaultLocale)

Find the ResourceBundle for this language without falling back to a default ResourceBundle in another language

Parameters:
targetBundle - The ResourceBundle we are looking for.
locale - The Locale object representing the language we want.
defaultLocale - The Locale object representing the default language.


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC