com.filenet.wcm.toolkit.util
Class WcmStringResources

java.lang.Object
  extended bycom.filenet.wcm.toolkit.util.WcmStringResources

public class WcmStringResources
extends java.lang.Object

This class manages String resources for various locales so that multiple locales WcmString and WcmException translations can be available simultaneously. For configuring additional ResourceParser resources, look at the add...BundleToPath signatures. String resources for a locale are loaded on demand, and reset to reload whenever one of the paths is changed.


Field Summary
protected static java.lang.String DEFAULT_LOCALE_VALUE
           
static java.lang.String EXCEPTION_CONFIG_NAME
           
protected static java.lang.String EXCEPTION_PREFIX
           
static java.lang.String SESSION_LOCALE_KEY
           
static java.lang.String STRING_CONFIG_NAME
           
protected static java.lang.String STRING_PREFIX
           
 
Constructor Summary
WcmStringResources()
           
 
Method Summary
static void addExceptionBundleToPath(ResourceBundle bundle)
          Use this call to define additional WcmException resource bundles so that they are picked up at runtime.
static void addExceptionBundleToPath(java.lang.String path, java.lang.String name)
          Use this call to define additional WcmException resource bundles so that they are picked up at runtime.
static void addExceptionJarBundleToPath(java.lang.String path, java.lang.String name, java.lang.Class loaderClass)
          Use this call to define additional WcmString resource bundles so that they are picked up at runtime.
static void addExceptionWarBundleToPath(java.lang.String path, java.lang.String name, javax.servlet.ServletContext application)
          Use this call to define additional WcmString resource bundles so that they are picked up at runtime.
static void addLegacyPRB(boolean exception, java.io.InputStream in)
          Deprecated. - Use add...BundleToPath sigs.
static void addLegacyPRB(boolean exception, java.util.Map m)
          Deprecated. - Use add...BundleToPath sigs.
static void addStringBundleToPath(ResourceBundle bundle)
          Use this call to define additional WcmString resource bundles so that they are picked up at runtime.
static void addStringBundleToPath(java.lang.String path, java.lang.String name)
          Use this call to define additional WcmString resource bundles so that they are picked up at runtime.
static void addStringJarBundleToPath(java.lang.String path, java.lang.String name, java.lang.Class loaderClass)
          Use this call to define additional WcmString resource bundles so that they are picked up at runtime.
static void addStringWarBundleToPath(java.lang.String path, java.lang.String name, javax.servlet.ServletContext application)
          Use this call to define additional WcmString resource bundles so that they are picked up at runtime.
static ResourceBundle getBundle(java.lang.String path, java.lang.String name)
          Factory method that creates a ResourceBundle object for resources stored directly on a local drive.
static java.util.Locale getClientLocale(javax.servlet.ServletRequest request)
          Get the locale to use for localization.
static java.lang.String getExceptionResource(java.util.Locale locale, java.lang.String key, java.lang.String defaultString)
          Retrieve an Exception resource by key for the specified locale.
static ResourceBundle getJarBundle(java.lang.String path, java.lang.String name, java.lang.Class loaderClass)
          Factory method that creates a ResourceBundle object relative to a JAR file.
static java.lang.String getStringResource(java.util.Locale locale, java.lang.String key, java.lang.String defaultString)
          Retrieve a String resource by key for the specified locale.
static ResourceBundle getWarBundle(java.lang.String path, java.lang.String name, javax.servlet.ServletContext application)
          Factory method that creates a ResourceBundle object relative to a WAR file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STRING_CONFIG_NAME

public static final java.lang.String STRING_CONFIG_NAME
See Also:
Constant Field Values

EXCEPTION_CONFIG_NAME

public static final java.lang.String EXCEPTION_CONFIG_NAME
See Also:
Constant Field Values

SESSION_LOCALE_KEY

public static final java.lang.String SESSION_LOCALE_KEY
See Also:
Constant Field Values

STRING_PREFIX

protected static final java.lang.String STRING_PREFIX
See Also:
Constant Field Values

EXCEPTION_PREFIX

protected static final java.lang.String EXCEPTION_PREFIX
See Also:
Constant Field Values

DEFAULT_LOCALE_VALUE

protected static final java.lang.String DEFAULT_LOCALE_VALUE
See Also:
Constant Field Values
Constructor Detail

WcmStringResources

public WcmStringResources()
Method Detail

getJarBundle

public static ResourceBundle getJarBundle(java.lang.String path,
                                          java.lang.String name,
                                          java.lang.Class loaderClass)
Factory method that creates a ResourceBundle object relative to a JAR file. To path in String resources that are located in a JAR file. Path represents the path within the JAR where the resource bundles are located. The ClassLoader used to load the specified Class determines which JAR file is referenced.

Parameters:
path - The path within the JAR. Leave blank to reference the package/directory where the class is located. Leading slash indicates relative to the JAR's root. No leading slash indicates relative to where the class is located.
name - The resource bundle name for example, "WcmStringConfiguration"
loaderClass - If defined, it's getResourceAsStream is used.
Returns:
The ResourceBundle object

getWarBundle

public static ResourceBundle getWarBundle(java.lang.String path,
                                          java.lang.String name,
                                          javax.servlet.ServletContext application)
                                   throws java.net.MalformedURLException
Factory method that creates a ResourceBundle object relative to a WAR file. Compile resources using the ResourceParser, and then package up the resulting resource configuration and resource files into a folder (preferably within ~/WEB-INF.

Parameters:
path - The path relative to the web application's root, where the resources are located.
name - The resource bundle name for example, "WcmStringConfiguration"
application - The ServletContext object.
Returns:
The ResourceBundle object
Throws:
java.net.MalformedURLException

getBundle

public static ResourceBundle getBundle(java.lang.String path,
                                       java.lang.String name)
Factory method that creates a ResourceBundle object for resources stored directly on a local drive. Compile resources using the ResourceParser, and then package up the resulting resource configuration and resource files into a folder (preferably within ~/WEB-INF.

Parameters:
path - The fully qualified local path to the location of the resources.
name - The resource bundle name for example, "WcmStringConfiguration"
Returns:
The ResourceBundle object

addStringBundleToPath

public static void addStringBundleToPath(ResourceBundle bundle)
Use this call to define additional WcmString resource bundles so that they are picked up at runtime.

Parameters:
bundle - - The ResourceBundle object to add.

addExceptionBundleToPath

public static void addExceptionBundleToPath(ResourceBundle bundle)
Use this call to define additional WcmException resource bundles so that they are picked up at runtime.

Parameters:
bundle - - The ResourceBundle object to add.

addStringJarBundleToPath

public static void addStringJarBundleToPath(java.lang.String path,
                                            java.lang.String name,
                                            java.lang.Class loaderClass)
Use this call to define additional WcmString resource bundles so that they are picked up at runtime. To path in String resources that are located in a JAR file. Path represents the path within the JAR where the resource bundles are located. The ClassLoader used to load the specified Class determines which JAR file is referenced.

Parameters:
path - The path within the JAR. Leave blank to reference the package/directory where the class is located. Leading slash indicates relative to the JAR's root. No leading slash indicates relative to where the class is located.
name - The resource bundle name for example, "WcmStringConfiguration"
loaderClass - If defined, it's getResourceAsStream is used.

addExceptionJarBundleToPath

public static void addExceptionJarBundleToPath(java.lang.String path,
                                               java.lang.String name,
                                               java.lang.Class loaderClass)
Use this call to define additional WcmString resource bundles so that they are picked up at runtime. To path in String resources that are located in a JAR file. Path represents the path within the JAR where the resource bundles are located. The ClassLoader used to load the specified Class determines which JAR file is referenced.

Parameters:
path - The path within the JAR. Leave blank to reference the package/directory where the class is located. Leading slash indicates relative to the JAR's root. No leading slash indicates relative to where the class is located.
name - The resource bundle name for example, "WcmStringConfiguration"
loaderClass -

addStringWarBundleToPath

public static void addStringWarBundleToPath(java.lang.String path,
                                            java.lang.String name,
                                            javax.servlet.ServletContext application)
                                     throws java.net.MalformedURLException
Use this call to define additional WcmString resource bundles so that they are picked up at runtime. This path entry references resources contained within the web application's WAR file. Compile resources using the ResourceParser, and then package up the resulting resource configuration and resource files into a folder (preferably within ~/WEB-INF.

Parameters:
path - The path relative to the web application's root, where the resources are located.
name - The resource bundle name for example, "WcmStringConfiguration"
application - The ServletContext object.
Throws:
java.net.MalformedURLException

addExceptionWarBundleToPath

public static void addExceptionWarBundleToPath(java.lang.String path,
                                               java.lang.String name,
                                               javax.servlet.ServletContext application)
                                        throws java.net.MalformedURLException
Use this call to define additional WcmString resource bundles so that they are picked up at runtime. This path entry references resources contained within the web application's WAR file. Compile resources using the ResourceParser, and then package up the resulting resource configuration and resource files into a folder (preferably within ~/WEB-INF.

Parameters:
path - The path relative to the web application's root, where the resources are located.
name - The resource bundle name for example, "WcmStringConfiguration"
application - The ServletContext object.
Throws:
java.net.MalformedURLException

addStringBundleToPath

public static void addStringBundleToPath(java.lang.String path,
                                         java.lang.String name)
Use this call to define additional WcmString resource bundles so that they are picked up at runtime. Compile resources using the ResourceParser, and then package up the resulting resource configuration and resource files into a folder (preferably within ~/WEB-INF.

Parameters:
path - The fully qualified local path to the location of the resources.
name - The resource bundle name for example, "WcmStringConfiguration"

addExceptionBundleToPath

public static void addExceptionBundleToPath(java.lang.String path,
                                            java.lang.String name)
Use this call to define additional WcmException resource bundles so that they are picked up at runtime. Compile resources using the ResourceParser, and then package up the resulting resource configuration and resource files into a folder (preferably within ~/WEB-INF.

Parameters:
path - The fully qualified local path to the location of the resources.
name - The resource bundle name for example, "WcmExceptionConfiguration"

addLegacyPRB

public static void addLegacyPRB(boolean exception,
                                java.io.InputStream in)
                         throws java.io.IOException
Deprecated. - Use add...BundleToPath sigs.

Throws:
java.io.IOException

addLegacyPRB

public static void addLegacyPRB(boolean exception,
                                java.util.Map m)
Deprecated. - Use add...BundleToPath sigs.


getStringResource

public static java.lang.String getStringResource(java.util.Locale locale,
                                                 java.lang.String key,
                                                 java.lang.String defaultString)
Retrieve a String resource by key for the specified locale. This is called internally by the "locale" instance methods found in WcmString.

Parameters:
locale -
key -
defaultString -
Returns:

getExceptionResource

public static java.lang.String getExceptionResource(java.util.Locale locale,
                                                    java.lang.String key,
                                                    java.lang.String defaultString)
Retrieve an Exception resource by key for the specified locale. This is called internally by the "locale" instance methods found in WcmException.

Parameters:
locale -
key -
defaultString -
Returns:

getClientLocale

public static java.util.Locale getClientLocale(javax.servlet.ServletRequest request)
Get the locale to use for localization. This method compares the locales enumeration from the request against the toolkit WcmStringConfiguration resources and returns the first match that is found.

Parameters:
request -
Returns:


© Copyright IBM Corp. 2002, 2007. All Rights Reserved.