org.apache.struts.util
クラス MessageResources

java.lang.Object
  拡張org.apache.struts.util.MessageResources
すべての実装インタフェース:
java.io.Serializable
直系の既知のサブクラス:
PropertyMessageResources

public abstract class MessageResources
extends java.lang.Object
implements java.io.Serializable

General purpose abstract class that describes an API for retrieving Locale-sensitive messages from underlying resource locations of an unspecified design, and optionally utilizing the MessageFormat class to produce internationalized messages with parametric replacement.

Calls to getMessage() variants without a Locale argument are presumed to be requesting a message string in the default Locale for this JVM.

Calls to getMessage() with an unknown key, or an unknown Locale will return null if the returnNull property is set to true. Otherwise, a suitable error message will be returned instead.

IMPLEMENTATION NOTE - Classes that extend this class must be Serializable so that instances may be used in distributable application server environments.

バージョン:
$Revision: 1.1 $ $Date: 2004/10/20 03:26:41 $
関連項目:
直列化された形式

フィールドの概要
protected  java.lang.String config
          The configuration parameter used to initialize this MessageResources.
protected static MessageResourcesFactory defaultFactory
          The default MessageResourcesFactory used to create MessageResources instances.
protected  java.util.Locale defaultLocale
          The default Locale for our environment.
protected  MessageResourcesFactory factory
          The MessageResourcesFactory that created this instance.
protected  java.util.HashMap formats
          The set of previously created MessageFormat objects, keyed by the key computed in messageKey().
protected static org.apache.commons.logging.Log log
          Commons Logging instance.
protected  boolean returnNull
          Indicate is a null is returned instead of an error message string when an unknown Locale or key is requested.
 
コンストラクタの概要
MessageResources(MessageResourcesFactory factory, java.lang.String config)
          Construct a new MessageResources according to the specified parameters.
MessageResources(MessageResourcesFactory factory, java.lang.String config, boolean returnNull)
          Construct a new MessageResources according to the specified parameters.
 
メソッドの概要
protected  java.lang.String escape(java.lang.String string)
          Escape any single quote characters that are included in the specified message string.
 java.lang.String getConfig()
          The configuration parameter used to initialize this MessageResources.
 MessageResourcesFactory getFactory()
          The MessageResourcesFactory that created this instance.
abstract  java.lang.String getMessage(java.util.Locale locale, java.lang.String key)
          Returns a text message for the specified key, for the default Locale.
 java.lang.String getMessage(java.util.Locale locale, java.lang.String key, java.lang.Object arg0)
          Returns a text message after parametric replacement of the specified parameter placeholders.
 java.lang.String getMessage(java.util.Locale locale, java.lang.String key, java.lang.Object[] args)
          Returns a text message after parametric replacement of the specified parameter placeholders.
 java.lang.String getMessage(java.util.Locale locale, java.lang.String key, java.lang.Object arg0, java.lang.Object arg1)
          Returns a text message after parametric replacement of the specified parameter placeholders.
 java.lang.String getMessage(java.util.Locale locale, java.lang.String key, java.lang.Object arg0, java.lang.Object arg1, java.lang.Object arg2)
          Returns a text message after parametric replacement of the specified parameter placeholders.
 java.lang.String getMessage(java.util.Locale locale, java.lang.String key, java.lang.Object arg0, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3)
          Returns a text message after parametric replacement of the specified parameter placeholders.
 java.lang.String getMessage(java.lang.String key)
          Returns a text message for the specified key, for the default Locale.
 java.lang.String getMessage(java.lang.String key, java.lang.Object arg0)
          Returns a text message after parametric replacement of the specified parameter placeholders.
 java.lang.String getMessage(java.lang.String key, java.lang.Object[] args)
          Returns a text message after parametric replacement of the specified parameter placeholders.
 java.lang.String getMessage(java.lang.String key, java.lang.Object arg0, java.lang.Object arg1)
          Returns a text message after parametric replacement of the specified parameter placeholders.
 java.lang.String getMessage(java.lang.String key, java.lang.Object arg0, java.lang.Object arg1, java.lang.Object arg2)
          Returns a text message after parametric replacement of the specified parameter placeholders.
 java.lang.String getMessage(java.lang.String key, java.lang.Object arg0, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3)
          Returns a text message after parametric replacement of the specified parameter placeholders.
static MessageResources getMessageResources(java.lang.String config)
          Create and return an instance of MessageResources for the created by the default MessageResourcesFactory.
 boolean getReturnNull()
          Indicates that a null is returned instead of an error message string if an unknown Locale or key is requested.
 boolean isPresent(java.util.Locale locale, java.lang.String key)
          Return true if there is a defined message for the specified key in the specified Locale.
 boolean isPresent(java.lang.String key)
          Return true if there is a defined message for the specified key in the system default locale.
protected  java.lang.String localeKey(java.util.Locale locale)
          Compute and return a key to be used in caching information by a Locale.
 void log(java.lang.String message)
          Log a message to the Writer that has been configured for our use.
 void log(java.lang.String message, java.lang.Throwable throwable)
          Log a message and exception to the Writer that has been configured for our use.
protected  java.lang.String messageKey(java.util.Locale locale, java.lang.String key)
          Compute and return a key to be used in caching information by Locale and message key.
protected  java.lang.String messageKey(java.lang.String localeKey, java.lang.String key)
          Compute and return a key to be used in caching information by locale key and message key.
 void setReturnNull(boolean returnNull)
          Indicates that a null is returned instead of an error message string if an unknown Locale or key is requested.
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

log

protected static org.apache.commons.logging.Log log
Commons Logging instance.


config

protected java.lang.String config
The configuration parameter used to initialize this MessageResources.


defaultLocale

protected java.util.Locale defaultLocale
The default Locale for our environment.


factory

protected MessageResourcesFactory factory
The MessageResourcesFactory that created this instance.


formats

protected java.util.HashMap formats
The set of previously created MessageFormat objects, keyed by the key computed in messageKey().


returnNull

protected boolean returnNull
Indicate is a null is returned instead of an error message string when an unknown Locale or key is requested.


defaultFactory

protected static MessageResourcesFactory defaultFactory
The default MessageResourcesFactory used to create MessageResources instances.

コンストラクタの詳細

MessageResources

public MessageResources(MessageResourcesFactory factory,
                        java.lang.String config)
Construct a new MessageResources according to the specified parameters.

パラメータ:
factory - The MessageResourcesFactory that created us
config - The configuration parameter for this MessageResources

MessageResources

public MessageResources(MessageResourcesFactory factory,
                        java.lang.String config,
                        boolean returnNull)
Construct a new MessageResources according to the specified parameters.

パラメータ:
factory - The MessageResourcesFactory that created us
config - The configuration parameter for this MessageResources
returnNull - The returnNull property we should initialize with
メソッドの詳細

getConfig

public java.lang.String getConfig()
The configuration parameter used to initialize this MessageResources.

戻り値:
parameter used to initialize this MessageResources

getFactory

public MessageResourcesFactory getFactory()
The MessageResourcesFactory that created this instance.

戻り値:
MessageResourcesFactory that created instance

getReturnNull

public boolean getReturnNull()
Indicates that a null is returned instead of an error message string if an unknown Locale or key is requested.

戻り値:
true if null is returned if unknown key or locale is requested

setReturnNull

public void setReturnNull(boolean returnNull)
Indicates that a null is returned instead of an error message string if an unknown Locale or key is requested.

パラメータ:
returnNull - true Indicates that a null is returned if an unknown Locale or key is requested.

getMessage

public java.lang.String getMessage(java.lang.String key)
Returns a text message for the specified key, for the default Locale.

パラメータ:
key - The message key to look up

getMessage

public java.lang.String getMessage(java.lang.String key,
                                   java.lang.Object[] args)
Returns a text message after parametric replacement of the specified parameter placeholders.

パラメータ:
key - The message key to look up
args - An array of replacement parameters for placeholders

getMessage

public java.lang.String getMessage(java.lang.String key,
                                   java.lang.Object arg0)
Returns a text message after parametric replacement of the specified parameter placeholders.

パラメータ:
key - The message key to look up
arg0 - The replacement for placeholder {0} in the message

getMessage

public java.lang.String getMessage(java.lang.String key,
                                   java.lang.Object arg0,
                                   java.lang.Object arg1)
Returns a text message after parametric replacement of the specified parameter placeholders.

パラメータ:
key - The message key to look up
arg0 - The replacement for placeholder {0} in the message
arg1 - The replacement for placeholder {1} in the message

getMessage

public java.lang.String getMessage(java.lang.String key,
                                   java.lang.Object arg0,
                                   java.lang.Object arg1,
                                   java.lang.Object arg2)
Returns a text message after parametric replacement of the specified parameter placeholders.

パラメータ:
key - The message key to look up
arg0 - The replacement for placeholder {0} in the message
arg1 - The replacement for placeholder {1} in the message
arg2 - The replacement for placeholder {2} in the message

getMessage

public java.lang.String getMessage(java.lang.String key,
                                   java.lang.Object arg0,
                                   java.lang.Object arg1,
                                   java.lang.Object arg2,
                                   java.lang.Object arg3)
Returns a text message after parametric replacement of the specified parameter placeholders.

パラメータ:
key - The message key to look up
arg0 - The replacement for placeholder {0} in the message
arg1 - The replacement for placeholder {1} in the message
arg2 - The replacement for placeholder {2} in the message
arg3 - The replacement for placeholder {3} in the message

getMessage

public abstract 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.

パラメータ:
locale - The requested message Locale, or null for the system default Locale
key - The message key to look up

getMessage

public java.lang.String getMessage(java.util.Locale locale,
                                   java.lang.String key,
                                   java.lang.Object[] args)
Returns a text message after parametric replacement of the specified parameter placeholders. A null string result will be returned by this method if no resource bundle has been configured.

パラメータ:
locale - The requested message Locale, or null for the system default Locale
key - The message key to look up
args - An array of replacement parameters for placeholders

getMessage

public java.lang.String getMessage(java.util.Locale locale,
                                   java.lang.String key,
                                   java.lang.Object arg0)
Returns a text message after parametric replacement of the specified parameter placeholders. A null string result will never be returned by this method.

パラメータ:
locale - The requested message Locale, or null for the system default Locale
key - The message key to look up
arg0 - The replacement for placeholder {0} in the message

getMessage

public java.lang.String getMessage(java.util.Locale locale,
                                   java.lang.String key,
                                   java.lang.Object arg0,
                                   java.lang.Object arg1)
Returns a text message after parametric replacement of the specified parameter placeholders. A null string result will never be returned by this method.

パラメータ:
locale - The requested message Locale, or null for the system default Locale
key - The message key to look up
arg0 - The replacement for placeholder {0} in the message
arg1 - The replacement for placeholder {1} in the message

getMessage

public java.lang.String getMessage(java.util.Locale locale,
                                   java.lang.String key,
                                   java.lang.Object arg0,
                                   java.lang.Object arg1,
                                   java.lang.Object arg2)
Returns a text message after parametric replacement of the specified parameter placeholders. A null string result will never be returned by this method.

パラメータ:
locale - The requested message Locale, or null for the system default Locale
key - The message key to look up
arg0 - The replacement for placeholder {0} in the message
arg1 - The replacement for placeholder {1} in the message
arg2 - The replacement for placeholder {2} in the message

getMessage

public java.lang.String getMessage(java.util.Locale locale,
                                   java.lang.String key,
                                   java.lang.Object arg0,
                                   java.lang.Object arg1,
                                   java.lang.Object arg2,
                                   java.lang.Object arg3)
Returns a text message after parametric replacement of the specified parameter placeholders. A null string result will never be returned by this method.

パラメータ:
locale - The requested message Locale, or null for the system default Locale
key - The message key to look up
arg0 - The replacement for placeholder {0} in the message
arg1 - The replacement for placeholder {1} in the message
arg2 - The replacement for placeholder {2} in the message
arg3 - The replacement for placeholder {3} in the message

isPresent

public boolean isPresent(java.lang.String key)
Return true if there is a defined message for the specified key in the system default locale.

パラメータ:
key - The message key to look up

isPresent

public boolean isPresent(java.util.Locale locale,
                         java.lang.String key)
Return true if there is a defined message for the specified key in the specified Locale.

パラメータ:
locale - The requested message Locale, or null for the system default Locale
key - The message key to look up

escape

protected java.lang.String escape(java.lang.String string)
Escape any single quote characters that are included in the specified message string.

パラメータ:
string - The string to be escaped

localeKey

protected java.lang.String localeKey(java.util.Locale locale)
Compute and return a key to be used in caching information by a Locale. NOTE - The locale key for the default Locale in our environment is a zero length String.

パラメータ:
locale - The locale for which a key is desired

messageKey

protected java.lang.String messageKey(java.util.Locale locale,
                                      java.lang.String key)
Compute and return a key to be used in caching information by Locale and message key.

パラメータ:
locale - The Locale for which this format key is calculated
key - The message key for which this format key is calculated

messageKey

protected java.lang.String messageKey(java.lang.String localeKey,
                                      java.lang.String key)
Compute and return a key to be used in caching information by locale key and message key.

パラメータ:
localeKey - The locale key for which this cache key is calculated
key - The message key for which this cache key is calculated

getMessageResources

public static MessageResources getMessageResources(java.lang.String config)
Create and return an instance of MessageResources for the created by the default MessageResourcesFactory.

パラメータ:
config - Configuration parameter for this message bundle.

log

public void log(java.lang.String message)
Log a message to the Writer that has been configured for our use.

パラメータ:
message - The message to be logged

log

public void log(java.lang.String message,
                java.lang.Throwable throwable)
Log a message and exception to the Writer that has been configured for our use.

パラメータ:
message - The message to be logged
throwable - The exception to be logged


このドキュメントは、Ja-Jakartaにより訳されました。コメントがある場合は、report@jajakarta.orgまでお願いします。
Copyright (C) 2000-2004 - Apache Software Foundation