Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright © 2000, 2009, Oracle and/or its affiliates. All rights reserved.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bea.netuix.servlets.l10n
Class L10nResourceManager

    java.lang.Object
      com.bea.netuix.servlets.l10n.L10nResourceManager

    public class L10nResourceManager

extends Object

The `L10nResourceManager` helps resolve resources (such as JSP pages, static resources such as HTML files, images etc.) based on a given locale.

Given a resource path in the form `[dir]/[name]` where `[dir]` is the directory ("/" separated, relative to the web app root) and `[name]` is the name of the resource, this class resolves the path to a localized version, if available.

For resolving a resource to a localized version, this class expects the locale to be present in the path structure as a sub-directory.

For instance, the following localized resources are considered valid for a resource "/portlets/news/flash.jsp":

- /en_US/portlets/news/flash.jsp
- /fr_FR/portlets/news/flash.jsp
- /portlets/en_US/news/flash.jsp
- /portlets/fr_FR/news/flash.jsp
- /portlets/news/en_US/flash.jsp
- /portlets/news/fr_FR/flash.jsp

This class resolves a localized version of in the following search order:

- language_country_variant version
- language_country version
- language_variant version
- language version
- country_variant version
- country version
- Non-localized version

In order to enable this class to recognize newly added or deleted resources after server startup, enable hot deployment for classes via the WebLogic Server admin console.

Method Summary
`void` | `ensureReloaded()` Ensures that the cached resources are fresh. This method only has an effect when localization is enabled in netuix-config.xml and the server is not running in production mode.
`static L10nResourceManager` | `getInstance(javax.servlet.ServletContext context)` Returns an instance of `L10nResourceManager`.
`LocaleProvider` | `getLocaleProvider()` Retrieve the LocaleProvider.
`Enumeration<Locale>` | `getPreferredLocales(javax.servlet.ServletRequest request)` Accessor for getting an Enumeration of preferred locales based on both the request and the setting of the internal localeProvider object, which is optionally overrideable by developers.
`ArrayList<Locale>` | `getPreferredLocalesAsList(javax.servlet.ServletRequest request)` Accessor for getting an ordered collection of preferred locales.
`String` | `resolve(String path, Enumeration locales)` Resolves the given path per the given locales to a localized resource.
`String` | `resolve(String path, Enumeration locales, ResolvedLocale resolvedLocale)` Resolves the given path per the given locales to a localized resource.
`String` | `resolve(String path, javax.servlet.ServletRequest request)` Resolves the given path per the given locales to a localized resource.
`String` | `resolve(String path, javax.servlet.ServletRequest request, ResolvedLocale resolvedLocale)` Resolves the given path per the given locales to a localized resource.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### getInstance

    public static L10nResourceManager getInstance(javax.servlet.ServletContext context)

  Returns an instance of `L10nResourceManager`.

  Parameters
    `context` - servlet context
  Returns
    the singleton instance of L10nResourceManager

### ensureReloaded

    public void ensureReloaded()

  Ensures that the cached resources are fresh.

  This method only has an effect when localization is enabled in netuix-config.xml and the server is not running in production mode.

### getPreferredLocales

    public Enumeration<Locale> getPreferredLocales(javax.servlet.ServletRequest request)

  Accessor for getting an Enumeration of preferred locales based on both the request and the setting of the internal localeProvider object, which is optionally overrideable by developers.

  Parameters
    `request` - current `ServletRequest`
  Returns
    Enumeration containing preferred `Locale` objects as determined from the request by the configured `LocaleProvider`

### getPreferredLocalesAsList

    public ArrayList<Locale> getPreferredLocalesAsList(javax.servlet.ServletRequest request)

  Accessor for getting an ordered collection of preferred locales. Used in places where l10nManager cannot be used directly, but where a collection may be passed to a consumer of locales.

  Parameters
    `request` - current `ServletRequest`
  Returns
    `ArrayList` containing `Locale` objects

### resolve

    public String resolve(String path,
                          javax.servlet.ServletRequest request)

  Resolves the given path per the given locales to a localized resource. Applications may use this method to resolve resources such as JSP pages, or other static resources to locales.

  Parameters
    `path` - path to the resource
    `request` - current `ServletRequest`
  Returns
    the localized path to the resource if present, otherwise returns the default path to the resource.

### resolve

    public String resolve(String path,
                          javax.servlet.ServletRequest request,
                          ResolvedLocale resolvedLocale)

  Resolves the given path per the given locales to a localized resource. Applications may use this method to resolve resources such as JSP pages, or other static resources to locales.

  This version of resolve accepts an out argument that is populated with extra resolution information.

  Parameters
    `path` - path to the resource
    `request` - current `ServletRequest`
    `resolvedLocale` - `ResolvedLocale` object to populate with resolution information
  Returns
    the localized path to the resource if present, otherwise returns the default path to the resource.

### resolve

    public String resolve(String path,
                          Enumeration locales)

  Resolves the given path per the given locales to a localized resource. Applications may use this method to resolve resources such as JSP pages, or other static resources to locales.

  Parameters
    `path` - path to the resource
    `locales` - preferred `Locales` to use for resolution
  Returns
    the localized path to the resource if present, otherwise returns the default path to the resource.

### resolve

    public String resolve(String path,
                          Enumeration locales,
                          ResolvedLocale resolvedLocale)

  Resolves the given path per the given locales to a localized resource. Applications may use this method to resolve resources such as JSP pages, or other static resources to locales.

  This version of resolve accepts an out argument that is populated with extra resolution information.

  Parameters
    `path` - path to the resource
    `locales` - preferred `Locales` to use for resolution
    `resolvedLocale` - `ResolvedLocale` object to populate with resolution information
  Returns
    the localized path to the resource if present, otherwise returns the default path to the resource.

### getLocaleProvider

    public LocaleProvider getLocaleProvider()

  Retrieve the LocaleProvider.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2009, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.