org.codehaus.spice.salt.i18n
Class I18nResources

java.lang.Object
  extended byorg.codehaus.spice.salt.i18n.I18nResources
Direct Known Subclasses:
Resources

public class I18nResources
extends Object

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

Author:
Peter Donald

Field Summary
protected  String m_baseName
          Base name of resource bundle.
protected  ClassLoader m_classLoader
          ClassLoader from which to load resources.
protected  Locale m_locale
          Local of Resources.
 
Constructor Summary
I18nResources(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
 

Field Detail

m_locale

protected final Locale m_locale
Local of Resources.


m_baseName

protected final String m_baseName
Base name of resource bundle.


m_classLoader

protected final ClassLoader m_classLoader
ClassLoader from which to load resources.

Constructor Detail

I18nResources

public I18nResources(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
Throws:
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
Throws:
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
Throws:
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
Throws:
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
Throws:
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
Throws:
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
Throws:
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
Throws:
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
Throws:
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
Throws:
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
Throws:
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
Throws:
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-2007 Codehaus. All Rights Reserved.