com.iplanet.jato.model
Class ResourceBundleModel

java.lang.Object
  |
  +--com.iplanet.jato.model.ResourceBundleModel
All Implemented Interfaces:
Model

public class ResourceBundleModel
extends java.lang.Object
implements Model

Provides a model implementation backed by a java.util.ResourceBundle . This model can be used to automatically bind display fields to locale-specific content.The bound name of display fields must correspond exactly to the name of a key in the backing bundle.

Version:
JATO/1.2.2 $Id: ResourceBundleModel.java,v 1.4 2002/03/16 03:26:31 todd Exp $
See Also:
Locale, ResourceBundle

Constructor Summary
ResourceBundleModel()
          This constructor is used when the model is created by the ModelManager.
ResourceBundleModel(java.util.ResourceBundle bundle)
          Create an instance with the specified ResourceBundle
ResourceBundleModel(java.lang.String bundleName)
          Create an instance with the specified ResourceBundle name.
ResourceBundleModel(java.lang.String bundleName, java.util.Locale locale)
          Create an instance with the specified ResourceBundle name and locale.
 
Method Summary
 java.lang.String getName()
          Returns the logical instance name of this model.
 java.util.ResourceBundle getResourceBundle()
          Returns the current ResourceBundle used by this model
 java.lang.Object getValue(java.lang.String name)
          Returns the named value from the backing ResourceBundle
 java.lang.Object[] getValues(java.lang.String name)
          Returns the named value array from the backing ResourceBundle.
 void loadBundle(java.lang.String bundleName)
          Causes the Model to (re)load its ResourceBundle
 void loadBundle(java.lang.String bundleName, java.util.Locale locale)
          Causes the Model to (re)load its ResourceBundle
 void setName(java.lang.String value)
          Sets the logical name of this model
 void setResourceBundle(java.util.ResourceBundle value)
          Sets the current ResourceBundle used by this model
 void setValue(java.lang.String name, java.lang.Object value)
          Note: this method has no effect.
 void setValues(java.lang.String name, java.lang.Object[] value)
          Note: this method has no effect.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceBundleModel

public ResourceBundleModel()
This constructor is used when the model is created by the ModelManager. Since this constructor does not accept any parameters, the client must explicitly set the ResourceBundle or invoke one of the loadBundle() methods after construction or after retrieving the model from the ModelManager.

ResourceBundleModel

public ResourceBundleModel(java.util.ResourceBundle bundle)
Create an instance with the specified ResourceBundle
Parameters:
bundle - A ResourceBundle
Throws:
java.lang.IllegalArgumentException - Thrown if the bundle parameter is null

ResourceBundleModel

public ResourceBundleModel(java.lang.String bundleName)
Create an instance with the specified ResourceBundle name. The named ResourceBundle will be loaded during construction.
Parameters:
bundleName - The name of a ResourceBundle
Throws:
java.lang.IllegalArgumentException - Thrown if the bundleName parameter is null

ResourceBundleModel

public ResourceBundleModel(java.lang.String bundleName,
                           java.util.Locale locale)
Create an instance with the specified ResourceBundle name and locale. The named ResourceBundle will be loaded during construction.
Parameters:
bundleName - The name of a ResourceBundle
locale - The Locale to use when looking up the ResourceBundle
Throws:
java.lang.IllegalArgumentException - Thrown if the bundleName parameter or the locale parameter is null
Method Detail

getName

public java.lang.String getName()
Description copied from interface: Model
Returns the logical instance name of this model. This name can be any arbitrary string. This name may only be useful at certain times; for example, the ModelManager may assign a name to a model based on user request.
Specified by:
getName in interface Model
Following copied from interface: com.iplanet.jato.model.Model
Returns:
The opaque, arbitrary name of this model

setName

public void setName(java.lang.String value)
Description copied from interface: Model
Sets the logical name of this model
Specified by:
setName in interface Model
Following copied from interface: com.iplanet.jato.model.Model
Parameters:
name - The new name of this model

loadBundle

public void loadBundle(java.lang.String bundleName)
Causes the Model to (re)load its ResourceBundle
Parameters:
bundleName - The name of a ResourceBundle. This value cannot be null.

loadBundle

public void loadBundle(java.lang.String bundleName,
                       java.util.Locale locale)
Causes the Model to (re)load its ResourceBundle
Parameters:
bundleName - The name of a ResourceBundle. This value cannot be null.
locale - The Locale to use when looking up the ResourceBundle. This locale may be null.
Throws:
java.util.MissingResourceException - Thrown if the ResourceBundle cannot be located

getResourceBundle

public java.util.ResourceBundle getResourceBundle()
Returns the current ResourceBundle used by this model

setResourceBundle

public void setResourceBundle(java.util.ResourceBundle value)
Sets the current ResourceBundle used by this model
Parameters:
value - The ResourceBundle instance to be used. This parameter cannot be null.

getValue

public java.lang.Object getValue(java.lang.String name)
Returns the named value from the backing ResourceBundle
Specified by:
getValue in interface Model
Returns:
The named value, or null if the ResourceBundle has not yet been initialized.

setValue

public void setValue(java.lang.String name,
                     java.lang.Object value)
Note: this method has no effect. Values cannot be set on this model type.
Specified by:
setValue in interface Model
Following copied from interface: com.iplanet.jato.model.Model
Parameters:
name - The name of the value to set
value - The value to set in this model

getValues

public java.lang.Object[] getValues(java.lang.String name)
Returns the named value array from the backing ResourceBundle. This method wraps singular values as arrays, and returns array values directly (without wrapping them in another array).
Specified by:
getValues in interface Model
Returns:
The named value array, or a zero-length array if the ResourceBundle has not yet been initialized.

setValues

public void setValues(java.lang.String name,
                      java.lang.Object[] value)
Note: this method has no effect. Values cannot be set on this model type.
Specified by:
setValues in interface Model
Following copied from interface: com.iplanet.jato.model.Model
Parameters:
name - The name of the value set to set in the model
values - The set of values to set in this model