to.etc.webapp.nls
Class NlsContext

java.lang.Object
  extended by to.etc.webapp.nls.NlsContext

public final class NlsContext
extends java.lang.Object

Static accessor class to the current locale, "jargon" and currency information. This class behaves as a static class but has threadlocal based storage behind it; this allows the locale information to be different for every request. The actual locale to use for a request can be set by a server on a per-request basis. If no per-request locale is set this uses the default locale.

In addition, this also contains the current "currency locale" which is set once per application, when used. By default most applications will contain monetary amounts in a single currency only, regardless of the language they are being used in. For instance a dutch system can present information in English for a british user, but will still present amounts in euro's, not pounds.

Author:
Frits Jalvingh Created on Jun 28, 2007

Method Summary
static NlsCodeTable createCodeTable(java.lang.String name)
          Create a coded translation table for code tables.
static BundleRef getBundleRef(java.lang.String bundlekey)
          Get the BundleRef for the specified bundle key.
static java.lang.String getCodeDescription(java.lang.String tablename, java.lang.String code, java.lang.String defmsg)
          FIXME This needs to use a cached code translation table from the database.
static java.util.Currency getCurrency()
          Returns a Currency object for the current currency locale.
static java.util.Locale getCurrencyLocale()
          The locale for the currency being handled in the application.
static java.lang.String getCurrencySymbol()
          Returns the currency symbol (not the currency code, damnit) for the current currency locale.
static java.text.DateFormat getDateFormat(int style)
           
static java.text.DateFormat getDateTimeFormat(int s1, int s2)
           
static java.util.Locale getDefault()
          Returns the default ViewPoint locale.
static java.util.Locale getDefaultCurrencyLocale()
           
static java.lang.String getDialect()
           
static java.util.Locale getLocale()
          Gets the current locale in use by the request we're executing at this time - this is the PROPER call to use from normal user code.
static void setCurrencyLocale(java.util.Locale loc)
          Sets the currency locale to use for this request.
static void setDefaultCurrencyLocale(java.util.Locale defaultCurrencyLocale)
           
static void setDialect(java.lang.String dialect)
           
static void setLocale(java.util.Locale loc)
          Sets the current locale.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDefault

public static java.util.Locale getDefault()
Returns the default ViewPoint locale. DO NOT USE!!!!, except when absolutely necessary! To get the actual locale that is being used by a request call getLocale()!

Returns:

setDefaultCurrencyLocale

public static void setDefaultCurrencyLocale(java.util.Locale defaultCurrencyLocale)

getDefaultCurrencyLocale

public static java.util.Locale getDefaultCurrencyLocale()

getCurrencyLocale

public static java.util.Locale getCurrencyLocale()

The locale for the currency being handled in the application. Can be changed per request, and defaults to the "default locale" (NOT the per request locale!). This is used for applications that use only a single currency throughout the application; if an application uses multiple currencies the application itself must provide services to handle the "current" currency and monetary conversions of currencies.

This will return the default locale if not explicitly set.

Returns:

setCurrencyLocale

public static void setCurrencyLocale(java.util.Locale loc)
Sets the currency locale to use for this request.

Parameters:
loc -

getCurrency

public static java.util.Currency getCurrency()
Returns a Currency object for the current currency locale.

Returns:

getCurrencySymbol

public static java.lang.String getCurrencySymbol()
Returns the currency symbol (not the currency code, damnit) for the current currency locale. This will return the euro sign € instead of EUR.

Returns:

getDialect

public static java.lang.String getDialect()

setDialect

public static void setDialect(java.lang.String dialect)

getLocale

public static java.util.Locale getLocale()
Gets the current locale in use by the request we're executing at this time - this is the PROPER call to use from normal user code.

Returns:

setLocale

public static void setLocale(java.util.Locale loc)
Sets the current locale. DO NOT USE!!!!! This method should ONLY be called from system (server) code! It sets the per-request locale.

Parameters:
loc -

getBundleRef

public static BundleRef getBundleRef(java.lang.String bundlekey)
Get the BundleRef for the specified bundle key. This represents a given set of messages for all possible locales.

Parameters:
bundlekey - The key (package/filename) of the resource bundle without .properties!
Returns:

getDateFormat

public static java.text.DateFormat getDateFormat(int style)

getDateTimeFormat

public static java.text.DateFormat getDateTimeFormat(int s1,
                                                     int s2)

createCodeTable

public static NlsCodeTable createCodeTable(java.lang.String name)
Create a coded translation table for code tables. FIXME Needs real implementation.


getCodeDescription

public static java.lang.String getCodeDescription(java.lang.String tablename,
                                                  java.lang.String code,
                                                  java.lang.String defmsg)
FIXME This needs to use a cached code translation table from the database.