com.waveset.msgcat
Class CustomCatalogSet

java.lang.Object
  extended bycom.waveset.msgcat.CustomCatalogSet

public class CustomCatalogSet
extends java.lang.Object

Keeps an ordered list of message catalogs. The heirarchy looks something like this:

     
     A default custom catalog:
     
            CustomCatalog (_default_custom_catalog)
                  |
                  |-- CustomCatalog.MessageSet (en/US)
                  |            |
                  |            |-- CustomCatalog.Message
                  |            |-- CustomCatalog.Message
                  |            |-- ...
                  |
                  |-- CustomCatalog.MessageSet (fr/CA)
                  |            |
                  |            |-- CustomCatalog.Message
                  |            |-- CustomCatalog.Message
                  |            |-- ...
                  |
                  |-- ...
      
      
     An ordered list of catalogs (ordered by precedence, LIFO)
      
            CustomCatalog (first)
                  |
                  |-- CustomCatalog.MessageSet (en/US)
                  |               |
                  |               |-- CustomCatalog.Message
                  |               |-- CustomCatalog.Message
                  |               |-- ...
                  |
                  |-- CustomCatalog.MessageSet (fr/CA)
                  |               |
                  |               |-- CustomCatalog.Message
                  |               |-- CustomCatalog.Message
                  |               |-- ...
                  |
                  |-- ...
                  |
            CustomCatalog (second)
                  |
                  |-- CustomCatalog.MessageSet (en/US)
                  |               |
                  |               |-- CustomCatalog.Message
                  |               |-- CustomCatalog.Message
                  |               |-- ...
                  |
                  |-- CustomCatalog.MessageSet (fr/CA)
                  |               |
                  |               |-- CustomCatalog.Message
                  |               |-- CustomCatalog.Message
                  |               |-- ...
                  |
                  |-- ...


 


Field Summary
static java.lang.String code_id
           
static java.lang.String DEFAULT
          Used to identify the "default" catalog.
 
Constructor Summary
CustomCatalogSet()
          Default constructor.
 
Method Summary
static void add(CustomCatalog cc)
          Add the given catalog to the set of custom catalogs.
static CustomCatalog[] getAll()
          Get a list of the custom catalogs in order of precedence.
static CustomCatalog getDefault()
          Gets the default custom catalog.
 java.lang.String localize(java.lang.String id, java.lang.Object[] parameters, java.util.Locale locale)
          Attempts to find and localize the message corresponding with the given id for the given locale, using the given parameters if necessary.
static void remove(java.lang.String cc_id)
          Remove the given custom catalog.
static void setDefault(CustomCatalog cc)
          Set the given catalog as the default.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

code_id

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

DEFAULT

public static final java.lang.String DEFAULT
Used to identify the "default" catalog.

See Also:
Constant Field Values
Constructor Detail

CustomCatalogSet

public CustomCatalogSet()
Default constructor.

Method Detail

setDefault

public static void setDefault(CustomCatalog cc)
Set the given catalog as the default.

Parameters:
cc - The catalog to set as default.

add

public static void add(CustomCatalog cc)
Add the given catalog to the set of custom catalogs.

Parameters:
cc - The catalog to add.

getAll

public static CustomCatalog[] getAll()
Get a list of the custom catalogs in order of precedence. The default catalog must be retrived seperately.

Returns:
A list of the custom catalogs.

getDefault

public static CustomCatalog getDefault()
Gets the default custom catalog.

Returns:
The default custom catalog.

remove

public static void remove(java.lang.String cc_id)
Remove the given custom catalog.

Parameters:
cc_id - Id of the custom catalog.

localize

public java.lang.String localize(java.lang.String id,
                                 java.lang.Object[] parameters,
                                 java.util.Locale locale)
Attempts to find and localize the message corresponding with the given id for the given locale, using the given parameters if necessary.

Parameters:
id - Id of the message to localize.
parameters - Values to use for substitution into the message placeholders.
locale - The locale to use.
Returns:
If the id is found for either the given or default locale, a localized string. Otherwise, null.