Skip navigation links


com.essbase.eas.i18n
Class ResourceUtilities

java.lang.Object
  extended by com.essbase.eas.i18n.ResourceUtilities


public abstract class ResourceUtilities
extends java.lang.Object

this is a utility class containing some static methods for handling resource bundles. All calls to ResourceBundler.getBundle() should be replaced by calls to ResourceUtilities.getBundle() and All calls to bundle.getString() should be replaced by calls to ResourceUtilities.getStringSafely(). This is a value added solution that catches the appropriate exceptions and tries to provide a reasonable default handling. For instance, calls to getStringSafely() will return the key if the resource bundle is null or the resource is missing. While there is no guarantee that the getBundle() calls implemented here will never return a null value, the chances should be so remote that checking shouldn't be necessary. The same is true of the getStringSafely() call.

Since:
6.5.1
Version:
6.5.2, 09/16/2002
Author:
Hank Cox

Method Summary
static java.util.ResourceBundle getBundle(java.lang.Class clazz)
           
static java.util.ResourceBundle getBundle(java.lang.Class c, java.util.Locale locale)
          return a resource bundle for a specific class.
static java.util.ResourceBundle getBundle(java.lang.Class c, java.util.Locale locale, boolean allClasses)
           
static java.util.ResourceBundle getBundle(java.lang.Class c, java.util.Locale locale, java.lang.ClassLoader loader)
          return a resource bundle for a specific class.
static java.util.ResourceBundle getBundle(java.lang.Class c, java.util.Locale locale, java.lang.ClassLoader loader, boolean allClasses)
           
static java.util.ResourceBundle getBundle(java.lang.String baseName)
          return a resource bundle or null if the bundle doesn't exist.
static java.util.ResourceBundle getBundle(java.lang.String baseName, java.util.Locale locale)
          return a resource bundle or null if the bundle doesn't exist.
static java.util.ResourceBundle[] getBundles(java.lang.Class clazz)
           
static java.util.ResourceBundle[] getBundles(java.lang.Class c, java.util.Locale locale)
           
static java.lang.String getFormattedMessage(java.util.ResourceBundle bundle, java.lang.String patternKey, java.lang.Object[] arguments)
          This function is a utility to return a formatted message.
static javax.swing.ImageIcon getIcon(java.lang.Class cl)
           
static javax.swing.ImageIcon getIcon(java.lang.Class cl, java.lang.String name)
           
static int getIntegerSafely(java.util.ResourceBundle b, java.lang.String key, int defaultValue)
          returns an integer from a resource bundle, checking for exceptions.
static java.io.InputStream getLocaleHtmlFile(java.lang.Class sourceClass, java.lang.String htmlFileName)
           
static java.lang.String getLocaleHtmlFile(java.lang.String html)
           
static java.lang.String getLocaleHtmlFileLanguageOnly(java.lang.String html)
           
static java.lang.String getStringSafely(java.lang.Class cl, java.lang.String key)
           
static java.lang.String getStringSafely(java.util.ResourceBundle[] b, java.lang.String key)
           
static java.lang.String getStringSafely(java.util.ResourceBundle b, java.lang.String key)
          returns a string from a resource bundle, checking for exceptions.
static java.lang.String getStringSafely(java.util.ResourceBundle b, java.lang.String key, java.lang.String defaultValue)
          returns a string from a resource bundle, checking for exceptions.
static void setClassFinder(ClassFinder classfinder)
           

 

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

 

Method Detail

getBundle

public static java.util.ResourceBundle getBundle(java.lang.String baseName)
return a resource bundle or null if the bundle doesn't exist. This method is guarenteed (well, mostly) to never return a null pointer.

getBundles

public static java.util.ResourceBundle[] getBundles(java.lang.Class clazz)

getBundle

public static java.util.ResourceBundle getBundle(java.lang.Class clazz)

getBundle

public static java.util.ResourceBundle getBundle(java.lang.String baseName,
                                                 java.util.Locale locale)
return a resource bundle or null if the bundle doesn't exist. This method is guarenteed (well, mostly) to never return a null pointer.

getBundles

public static java.util.ResourceBundle[] getBundles(java.lang.Class c,
                                                    java.util.Locale locale)

getBundle

public static java.util.ResourceBundle getBundle(java.lang.Class c,
                                                 java.util.Locale locale)
return a resource bundle for a specific class. We get the package name of the class interested in, insert the ".resources" between the package name and the end of the class name, and then look for that properties bundle.

getBundle

public static java.util.ResourceBundle getBundle(java.lang.Class c,
                                                 java.util.Locale locale,
                                                 boolean allClasses)

getBundle

public static java.util.ResourceBundle getBundle(java.lang.Class c,
                                                 java.util.Locale locale,
                                                 java.lang.ClassLoader loader)
return a resource bundle for a specific class. We get the package name of the class interested in, insert the ".resources" between the package name and the end of the class name, and then look for that properties bundle.

getBundle

public static java.util.ResourceBundle getBundle(java.lang.Class c,
                                                 java.util.Locale locale,
                                                 java.lang.ClassLoader loader,
                                                 boolean allClasses)

getIntegerSafely

public static int getIntegerSafely(java.util.ResourceBundle b,
                                   java.lang.String key,
                                   int defaultValue)
returns an integer from a resource bundle, checking for exceptions. If the resource bundle is null or the string representing the integer doesn't exist in the bundle, then the method will return the default value. It should go without saying that the key should never be a null value.

getStringSafely

public static java.lang.String getStringSafely(java.lang.Class cl,
                                               java.lang.String key)

getStringSafely

public static java.lang.String getStringSafely(java.util.ResourceBundle[] b,
                                               java.lang.String key)

getStringSafely

public static java.lang.String getStringSafely(java.util.ResourceBundle b,
                                               java.lang.String key)
returns a string from a resource bundle, checking for exceptions. This method should always return at least an empty string and should never return a null. If the resource bundle is null or the string doesn't exist in the bundle, then the method will return the key. It should go without saying that the key should never be a null value.

getStringSafely

public static java.lang.String getStringSafely(java.util.ResourceBundle b,
                                               java.lang.String key,
                                               java.lang.String defaultValue)
returns a string from a resource bundle, checking for exceptions. This method should always return at least an empty string and should never return a null. If the resource bundle is null or the string doesn't exist in the bundle, then the method will return the default value. It should go without saying that the key should never be a null value.

getFormattedMessage

public static java.lang.String getFormattedMessage(java.util.ResourceBundle bundle,
                                                   java.lang.String patternKey,
                                                   java.lang.Object[] arguments)
This function is a utility to return a formatted message.
Parameters:
bundle - The resource bundle to be used to find the patternKey
patternKey - is the format string
arguments - are the arguments supplied to the format string

setClassFinder

public static void setClassFinder(ClassFinder classfinder)

getLocaleHtmlFile

public static java.lang.String getLocaleHtmlFile(java.lang.String html)

getLocaleHtmlFileLanguageOnly

public static java.lang.String getLocaleHtmlFileLanguageOnly(java.lang.String html)

getLocaleHtmlFile

public static java.io.InputStream getLocaleHtmlFile(java.lang.Class sourceClass,
                                                    java.lang.String htmlFileName)

getIcon

public static javax.swing.ImageIcon getIcon(java.lang.Class cl)

getIcon

public static javax.swing.ImageIcon getIcon(java.lang.Class cl,
                                            java.lang.String name)

Skip navigation links


Copyright © 2001, 2012, Oracle. All rights reserved.