Oracle® Globalization Development Kit Java API Reference
10g Release 1(10.1)

B10971-01

oracle.i18n.servlet
Class ApplicationContext

java.lang.Object
  |
  +--oracle.i18n.servlet.ApplicationContext

public class ApplicationContext
extends Object

ApplicationContext is an application context class that controles application scope operations in the framework.

An instance of this object must be created at the time of start up of the application either in the ContextListener object or in a custom context listener for Java/JSP server side applications. A custom context listener must be present to use a custom LocaleSource object to access either locale information in the database or the ResourceBundle object in the user classpath.

The following example shows how to use contextInitialized and contextDestroyed methods. Note that the constructor throws exceptions.

  public void contextInitialized(ServletContextEvent event)
  {
    ...
    try
    {
      ServletContext context = event.getServletContext();
      context.setAttribute(
        ApplicationContext.OBJECT_KEY,
        new ApplicationContext(
          context.getResourceAsStream(ApplicationContext.DEFAULT_GDKAPP),
          getClass().getClassLoader()));
    {
    catch (except)
    {
      // handle exception
      ...
    }
    ...
  }
  ...
  public void contextDestroyed(ServletContextEvent event)
  {
    event.getServletContext().removeAttribute(ApplicationContext.OBJECT_KEY);
  }
  

Since:
10.1.0.2

Field Summary
static String DEFAULT_GDKAPP
           
static String OBJECT_KEY
           
 
Constructor Summary
ApplicationContext(InputStream pathToConfigFile)
          Constructs this object based on the application configuration file.
ApplicationContext(InputStream pathToConfigFile, ClassLoader cloader)
          Constructs this object based on the application configuration file and the ClassLoader object.
ApplicationContext(String pathToConfigFile)
          Constructs this object based on the application configuration file.
ApplicationContext(String pathToConfigFile, ClassLoader cloader)
          Constructs this object based on the application configuration file and the ClassLoader object.
 
Method Summary
 Locale fallbackLocale(Locale locale)
          Validates if the locale supplied as argument is supported.
 oracle.i18n.servlet.localesource.LocaleSource getApplicationDefaultLocaleSource()
          Returns the application default locale source instance.
 String getIANAPageCharacterSet()
          Returns the default IANA page character set name of the application or the string "AUTO-CHARSET".
 Class[] getLocaleSources()
          Returns locale sources examined in this order to determine the current locale.
 Map getMessageBundle()
          Returns the map of message bundle object
 String getParameterName(LocaleSource.Parameter parameter)
          Returns a String representing the parameter name used to specify locale attributes.
 String[] getSupportedIANACharacterSets()
          Returns supported IANA character sets
 Locale[] getSupportedLocales()
          Returns locales supported in the application.
 String[] getSupportedOraLanguages()
          Returns supported Oracle languages.
 String[] getSupportedOraLanguages(String oraTerritory)
          Returns supported Oracle languages for the Oracle territory The supported languages are determined by the supported locale.
 String[] getSupportedOraTerritories()
          Returns supported Oracle territories The supported territories are determined by the supported locale.
 String[] getSupportedOraTerritories(String oraLanguage)
          Returns supported Oracle territories for Oracle language The supported territories are determined by the supported locale.
 int hashCode()
          Returns the hash value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OBJECT_KEY

public static final String OBJECT_KEY
See Also:
Constant Field Values

DEFAULT_GDKAPP

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

ApplicationContext

public ApplicationContext(String pathToConfigFile)
                   throws ClassNotFoundException,
                          org.apache.regexp.RESyntaxException,
                          UnsupportedEncodingException
Constructs this object based on the application configuration file. ClassLoader is derived from this object.

Parameters:
pathToConfigFile - an absolute file path of the application configuration file.
Throws:
ClassNotFoundException - if locale source class is not found
org.apache.regexp.RESyntaxException - if rewriting rule or locale to charset mapping regular expression is invalid
UnsupportedEncodingException - if character set is invalid

ApplicationContext

public ApplicationContext(InputStream pathToConfigFile)
                   throws ClassNotFoundException,
                          org.apache.regexp.RESyntaxException,
                          UnsupportedEncodingException
Constructs this object based on the application configuration file. ClassLoader is derived from this object.

Parameters:
pathToConfigFile - an input stream object that references the application configuration file.
Throws:
ClassNotFoundException - if locale source class is not found
org.apache.regexp.RESyntaxException - if rewriting rule or locale to charset mapping regular expression is invalid
UnsupportedEncodingException - if character set is invalid

ApplicationContext

public ApplicationContext(String pathToConfigFile,
                          ClassLoader cloader)
                   throws ClassNotFoundException,
                          org.apache.regexp.RESyntaxException,
                          UnsupportedEncodingException
Constructs this object based on the application configuration file and the ClassLoader object. The class loader is required if you use a custom LocaleSource and specify it in the application configuration file.

Parameters:
pathToConfigFile - an absolute file path of the application configuration file.
cloader - a class loader class used
Throws:
ClassNotFoundException - if locale source class is not found
org.apache.regexp.RESyntaxException - if rewriting rule or locale to charset mapping regular expression is invalid
UnsupportedEncodingException - if character set is invalid

ApplicationContext

public ApplicationContext(InputStream pathToConfigFile,
                          ClassLoader cloader)
                   throws ClassNotFoundException,
                          org.apache.regexp.RESyntaxException,
                          UnsupportedEncodingException
Constructs this object based on the application configuration file and the ClassLoader object. The class loader is required if you use a custom LocaleSource and specify it in the application configuration file.

Parameters:
pathToConfigFile - an input stream object that references the application configuration file.
cloader - a class loader class used
Throws:
ClassNotFoundException - if locale source class is not found
org.apache.regexp.RESyntaxException - if rewriting rule or locale to charset mapping regular expression is invalid
UnsupportedEncodingException - if character set is invalid
Method Detail

getIANAPageCharacterSet

public String getIANAPageCharacterSet()
Returns the default IANA page character set name of the application or the string "AUTO-CHARSET".

To retrieve the actual name of character set, use Localizer.getIANACharacterSet()

Returns:
a IANA character set name or AUTO-CHARSET

getParameterName

public String getParameterName(LocaleSource.Parameter parameter)
Returns a String representing the parameter name used to specify locale attributes. For example, if you want to get the locale value, use LocaleSource.LOCALE as an input:
 ApplicationContext appctx = ServletHelper.getApplicationContextInstance(
   request);
 String plocale = request.getParameter(
   appctx.getParameterName(LocaleSource.LOCALE));
 

Parameters:
parameter - a parameter type.
Returns:
a parameter name used in the application.

getLocaleSources

public Class[] getLocaleSources()
Returns locale sources examined in this order to determine the current locale.

Returns:
an array of LocaleSource classes

getApplicationDefaultLocaleSource

public oracle.i18n.servlet.localesource.LocaleSource getApplicationDefaultLocaleSource()
Returns the application default locale source instance.

Returns:
a LocaleSource representing the application default locale.

getMessageBundle

public Map getMessageBundle()
Returns the map of message bundle object

Returns:
the map of message bundle object

getSupportedLocales

public Locale[] getSupportedLocales()
Returns locales supported in the application.

The supported locale can be specified in the application configration file.

Returns:
an array of Locale representing supported locales in the application.

getSupportedOraLanguages

public String[] getSupportedOraLanguages(String oraTerritory)
Returns supported Oracle languages for the Oracle territory

The supported languages are determined by the supported locale.

Parameters:
oraTerritory - Oracle territory name
Returns:
an array of String representing the supported languages in the application.

getSupportedOraLanguages

public String[] getSupportedOraLanguages()
Returns supported Oracle languages.

The supported languages are determined by the supported locale.

Returns:
an array of String representing the supported languages in the application.

getSupportedOraTerritories

public String[] getSupportedOraTerritories(String oraLanguage)
Returns supported Oracle territories for Oracle language

The supported territories are determined by the supported locale.

Parameters:
oraLanguage - Oracle language name
Returns:
an array of String representing the supported territories in the application.

getSupportedOraTerritories

public String[] getSupportedOraTerritories()
Returns supported Oracle territories

The supported territories are determined by the supported locale. Sorting order is in English.

Returns:
an array of String representing the supported territories in the application.

getSupportedIANACharacterSets

public String[] getSupportedIANACharacterSets()
Returns supported IANA character sets

Returns:
an array of supported IANA character sets in the application.

fallbackLocale

public Locale fallbackLocale(Locale locale)
Validates if the locale supplied as argument is supported. If the locale is supported, it is returned by the method; otherwise, fallback locale is returned.

If you are not sure that the given locale is supported, call this method.

Note that supported locales in the application are not equivalent to the translation locales that are handled by ResourceBundle or ServletHelper.rewriteURL(String, HttpServletRequest). They validate locales by checking the actual translation resources; if the given locale's translation exists, it is returned, otherwise, it returns the fallback locale's traslation.

Parameters:
locale - a Locale object to be examined.
Returns:
a Locale that is supported by the application

hashCode

public int hashCode()
Returns the hash value

Overrides:
hashCode in class Object
Returns:
hash value

Oracle® Globalization Development Kit Java API Reference
10g Release 1(10.1)

B10971-01

Copyright © 2003 Oracle Corporation. All Rights Reserved.