Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.struts.util
Class PropertyMessageResources

    java.lang.Object
      |
      +--org.apache.struts.util.MessageResources
            |
            +--org.apache.struts.util.PropertyMessageResources

All Implemented Interfaces:
  java.io.Serializable

public class PropertyMessageResources
extends MessageResources

Concrete subclass of `MessageResources` that reads message keys and corresponding strings from named property resources in the same manner that `java.util.PropertyResourceBundle` does. The `base` property defines the base property resource name, and must be specified.

IMPLEMENTATION NOTE - This class trades memory for speed by caching all messages located via generalizing the Locale under the original locale as well. This results in specific messages being stored in the message cache more than once, but improves response time on subsequent requests for the same locale + key combination.

Version:
  $Revision: 1.1 $ $Date: 2001-09-17 21:13:30 +0100 (Mon, 17 Sep 2001) $
Author:
  Craig R. McClanahan
See Also:
  Serialized Form

Field Summary
`protected java.util.HashMap` | `locales` The set of locale keys for which we have already loaded messages, keyed by the value calculated in `localeKey()`.
`protected java.util.HashMap` | `messages` The cache of messages we have accumulated over time, keyed by the value calculated in `messageKey()`.

Fields inherited from class org.apache.struts.util.MessageResources
`config, defaultFactory, defaultLocale, factory, formats, returnNull`

Constructor Summary
`PropertyMessageResources(MessageResourcesFactory factory, java.lang.String config)` Construct a new PropertyMessageResources according to the specified parameters.
`PropertyMessageResources(MessageResourcesFactory factory, java.lang.String config, boolean returnNull)` Construct a new PropertyMessageResources according to the specified parameters.

Method Summary
`java.lang.String` | `getMessage(java.util.Locale locale, java.lang.String key)` Returns a text message for the specified key, for the default Locale.
`protected void` | `loadLocale(java.lang.String localeKey)` Load the messages associated with the specified Locale key.

Methods inherited from class org.apache.struts.util.MessageResources
`getConfig, getFactory, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessageResources, getReturnNull, isPresent, isPresent, localeKey, log, log, messageKey, messageKey, setReturnNull`

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

Field Detail

### locales

    protected java.util.HashMap locales

  The set of locale keys for which we have already loaded messages, keyed by the value calculated in `localeKey()`.

### messages

    protected java.util.HashMap messages

  The cache of messages we have accumulated over time, keyed by the value calculated in `messageKey()`.

Constructor Detail

### PropertyMessageResources

    public PropertyMessageResources(MessageResourcesFactory factory,
                                    java.lang.String config)

  Construct a new PropertyMessageResources according to the specified parameters.
  Parameters:
    `factory` - The MessageResourcesFactory that created us
    `config` - The configuration parameter for this MessageResources

### PropertyMessageResources

    public PropertyMessageResources(MessageResourcesFactory factory,
                                    java.lang.String config,
                                    boolean returnNull)

  Construct a new PropertyMessageResources according to the specified parameters.
  Parameters:
    `factory` - The MessageResourcesFactory that created us
    `config` - The configuration parameter for this MessageResources
    `returnNull` - The returnNull property we should initialize with

Method Detail

### getMessage

    public java.lang.String getMessage(java.util.Locale locale,
                                       java.lang.String key)

  Returns a text message for the specified key, for the default Locale. A null string result will be returned by this method if no relevant message resource is found for this key or Locale, if the `returnNull` property is set. Otherwise, an appropriate error message will be returned.

  This method must be implemented by a concrete subclass.

  Overrides:
    `getMessage` in class `MessageResources`
  Parameters:
    `locale` - The requested message Locale, or `null` for the system default Locale
    `key` - The message key to look up

### loadLocale

    protected void loadLocale(java.lang.String localeKey)

  Load the messages associated with the specified Locale key. For this implementation, the `config` property should contain a fully qualified package and resource name, separated by periods, of a series of property resources to be loaded from the class loader that created this PropertyMessageResources instance. This is exactly the same name format you would use when utilizing the `java.util.PropertyResourceBundle` class.
  Parameters:
    `localeKey` - Locale key for the messages to be retrieved

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2001 - Apache Software Foundation