org.codehaus.spice.salt.i18n
Class Resources

java.lang.Object
  |
  +--org.codehaus.spice.salt.i18n.Resources

public class Resources
extends Object

A class to simplify extracting localized strings, icons and other common resources from a ResourceBundle.

Version:
$Revision: 1.1 $ $Date: 2003/12/02 02:15:04 $
Author:
Peter Donald

Constructor Summary
Resources(String baseName, ClassLoader classLoader)
          Constructor that builds a manager in default locale using specified ClassLoader.
Resources(String baseName, Locale locale, ClassLoader classLoader)
          Constructor that builds a manager in specified locale.
 
Method Summary
 String format(String key, Object arg1)
          Retrieve a string from resource bundle and format it with specified args.
 String format(String key, Object[] args)
          Retrieve a string from resource bundle and format it with specified args.
 String format(String key, Object arg1, Object arg2)
          Retrieve a string from resource bundle and format it with specified args.
 String format(String key, Object arg1, Object arg2, Object arg3)
          Retrieve a string from resource bundle and format it with specified args.
 String format(String key, Object arg1, Object arg2, Object arg3, Object arg4)
          Retrieve a string from resource bundle and format it with specified args.
 String format(String key, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5)
          Retrieve a string from resource bundle and format it with specified args.
 boolean getBoolean(String key)
          Retrieve a boolean from bundle.
 boolean getBoolean(String key, boolean defaultValue)
          Retrieve a boolean from bundle.
 ResourceBundle getBundle()
          Retrieve underlying ResourceBundle.
 byte getByte(String key)
          Retrieve a byte from bundle.
 byte getByte(String key, byte defaultValue)
          Retrieve a byte from bundle.
 char getChar(String key)
          Retrieve a char from bundle.
 char getChar(String key, char defaultValue)
          Retrieve a char from bundle.
 Date getDate(String key)
          Retrieve a date from bundle.
 Date getDate(String key, Date defaultValue)
          Retrieve a date from bundle.
 Date getDateTime(String key)
          Retrieve a date + time from bundle.
 Date getDateTime(String key, Date defaultValue)
          Retrieve a time from bundle.
 double getDouble(String key)
          Retrieve a double from bundle.
 double getDouble(String key, double defaultValue)
          Retrieve a double from bundle.
 float getFloat(String key)
          Retrieve a float from bundle.
 float getFloat(String key, float defaultValue)
          Retrieve a float from bundle.
 int getInteger(String key)
          Retrieve a integer from bundle.
 int getInteger(String key, int defaultValue)
          Retrieve a integer from bundle.
 long getLong(String key)
          Retrieve a long from bundle.
 long getLong(String key, long defaultValue)
          Retrieve a long from bundle.
 short getShort(String key)
          Retrieve a short from bundle.
 short getShort(String key, short defaultValue)
          Retrieve a short from bundle.
 String getString(String key)
          Retrieve a raw string from bundle.
 String getString(String key, String defaultValue)
          Retrieve a raw string from bundle.
 Date getTime(String key)
          Retrieve a time from bundle.
 Date getTime(String key, Date defaultValue)
          Retrieve a time from bundle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Resources

public Resources(String baseName,
                 ClassLoader classLoader)
Constructor that builds a manager in default locale using specified ClassLoader.

Parameters:
baseName - the base name of ResourceBundle
classLoader - the classLoader to load ResourceBundle from

Resources

public Resources(String baseName,
                 Locale locale,
                 ClassLoader classLoader)
Constructor that builds a manager in specified locale.

Parameters:
baseName - the base name of ResourceBundle
locale - the Locale for resource bundle
classLoader - the classLoader to load ResourceBundle from
Method Detail

getBoolean

public boolean getBoolean(String key,
                          boolean defaultValue)
Retrieve a boolean from bundle.

Parameters:
key - the key of resource
defaultValue - the default value if key is missing
Returns:
the resource boolean

getBoolean

public boolean getBoolean(String key)
                   throws MissingResourceException
Retrieve a boolean from bundle.

Parameters:
key - the key of resource
Returns:
the resource boolean
MissingResourceException

getByte

public byte getByte(String key,
                    byte defaultValue)
Retrieve a byte from bundle.

Parameters:
key - the key of resource
defaultValue - the default value if key is missing
Returns:
the resource byte

getByte

public byte getByte(String key)
             throws MissingResourceException
Retrieve a byte from bundle.

Parameters:
key - the key of resource
Returns:
the resource byte
MissingResourceException

getChar

public char getChar(String key,
                    char defaultValue)
Retrieve a char from bundle.

Parameters:
key - the key of resource
defaultValue - the default value if key is missing
Returns:
the resource char

getChar

public char getChar(String key)
             throws MissingResourceException
Retrieve a char from bundle.

Parameters:
key - the key of resource
Returns:
the resource char
MissingResourceException

getShort

public short getShort(String key,
                      short defaultValue)
Retrieve a short from bundle.

Parameters:
key - the key of resource
defaultValue - the default value if key is missing
Returns:
the resource short

getShort

public short getShort(String key)
               throws MissingResourceException
Retrieve a short from bundle.

Parameters:
key - the key of resource
Returns:
the resource short
MissingResourceException

getInteger

public int getInteger(String key,
                      int defaultValue)
Retrieve a integer from bundle.

Parameters:
key - the key of resource
defaultValue - the default value if key is missing
Returns:
the resource integer

getInteger

public int getInteger(String key)
               throws MissingResourceException
Retrieve a integer from bundle.

Parameters:
key - the key of resource
Returns:
the resource integer
MissingResourceException

getLong

public long getLong(String key,
                    long defaultValue)
Retrieve a long from bundle.

Parameters:
key - the key of resource
defaultValue - the default value if key is missing
Returns:
the resource long

getLong

public long getLong(String key)
             throws MissingResourceException
Retrieve a long from bundle.

Parameters:
key - the key of resource
Returns:
the resource long
MissingResourceException

getFloat

public float getFloat(String key,
                      float defaultValue)
Retrieve a float from bundle.

Parameters:
key - the key of resource
defaultValue - the default value if key is missing
Returns:
the resource float

getFloat

public float getFloat(String key)
               throws MissingResourceException
Retrieve a float from bundle.

Parameters:
key - the key of resource
Returns:
the resource float
MissingResourceException

getDouble

public double getDouble(String key,
                        double defaultValue)
Retrieve a double from bundle.

Parameters:
key - the key of resource
defaultValue - the default value if key is missing
Returns:
the resource double

getDouble

public double getDouble(String key)
                 throws MissingResourceException
Retrieve a double from bundle.

Parameters:
key - the key of resource
Returns:
the resource double
MissingResourceException

getDate

public Date getDate(String key,
                    Date defaultValue)
Retrieve a date from bundle.

Parameters:
key - the key of resource
defaultValue - the default value if key is missing
Returns:
the resource date

getDate

public Date getDate(String key)
             throws MissingResourceException
Retrieve a date from bundle.

Parameters:
key - the key of resource
Returns:
the resource date
MissingResourceException

getTime

public Date getTime(String key,
                    Date defaultValue)
Retrieve a time from bundle.

Parameters:
key - the key of resource
defaultValue - the default value if key is missing
Returns:
the resource time

getTime

public Date getTime(String key)
             throws MissingResourceException
Retrieve a time from bundle.

Parameters:
key - the key of resource
Returns:
the resource time
MissingResourceException

getDateTime

public Date getDateTime(String key,
                        Date defaultValue)
Retrieve a time from bundle.

Parameters:
key - the key of resource
defaultValue - the default value if key is missing
Returns:
the resource time

getDateTime

public Date getDateTime(String key)
                 throws MissingResourceException
Retrieve a date + time from bundle.

Parameters:
key - the key of resource
Returns:
the resource date + time
MissingResourceException

getString

public String getString(String key)
                 throws MissingResourceException
Retrieve a raw string from bundle.

Parameters:
key - the key of resource
Returns:
the resource string
MissingResourceException

getString

public String getString(String key,
                        String defaultValue)
Retrieve a raw string from bundle.

Parameters:
key - the key of resource
defaultValue - the default value if key is missing
Returns:
the resource string

format

public String format(String key,
                     Object arg1)
Retrieve a string from resource bundle and format it with specified args.

Parameters:
key - the key for resource
arg1 - an arg
Returns:
the formatted string

format

public String format(String key,
                     Object arg1,
                     Object arg2)
Retrieve a string from resource bundle and format it with specified args.

Parameters:
key - the key for resource
arg1 - an arg
arg2 - an arg
Returns:
the formatted string

format

public String format(String key,
                     Object arg1,
                     Object arg2,
                     Object arg3)
Retrieve a string from resource bundle and format it with specified args.

Parameters:
key - the key for resource
arg1 - an arg
arg2 - an arg
arg3 - an arg
Returns:
the formatted string

format

public String format(String key,
                     Object arg1,
                     Object arg2,
                     Object arg3,
                     Object arg4)
Retrieve a string from resource bundle and format it with specified args.

Parameters:
key - the key for resource
arg1 - an arg
arg2 - an arg
arg3 - an arg
arg4 - an arg
Returns:
the formatted string

format

public String format(String key,
                     Object arg1,
                     Object arg2,
                     Object arg3,
                     Object arg4,
                     Object arg5)
Retrieve a string from resource bundle and format it with specified args.

Parameters:
key - the key for resource
arg1 - an arg
arg2 - an arg
arg3 - an arg
arg4 - an arg
arg5 - an arg
Returns:
the formatted string

format

public String format(String key,
                     Object[] args)
Retrieve a string from resource bundle and format it with specified args.

Parameters:
key - the key for resource
args - an array of args
Returns:
the formatted string

getBundle

public final ResourceBundle getBundle()
                               throws MissingResourceException
Retrieve underlying ResourceBundle. If bundle has not been loaded it will be loaded by this method. Access is given in case other resources need to be extracted that this Manager does not provide simplified access to.

Returns:
the ResourceBundle
Throws:
MissingResourceException - if an error occurs


Copyright © 1999-2003 Codehaus. All Rights Reserved.