| java.lang.Object org.apache.struts.util.MessageResources
All known Subclasses: org.apache.struts.util.PropertyMessageResources,
MessageResources | abstract public class MessageResources implements Serializable(Code) | | 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.
version: $Rev: 471754 $ $Date: 2005-08-29 23:57:50 -0400 (Mon, 29 Aug 2005) version: $ |
Field Summary | |
protected String | config The configuration parameter used to initialize this MessageResources. | protected static MessageResourcesFactory | defaultFactory The default MessageResourcesFactory used to create MessageResources
instances. | protected Locale | defaultLocale The default Locale for our environment. | protected MessageResourcesFactory | factory The MessageResourcesFactory that created this instance. | protected HashMap | formats The set of previously created MessageFormat objects, keyed by the key
computed in messageKey() . | protected static 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. |
Method Summary | |
protected String | escape(String string) Escape any single quote characters that are included in the specified
message string. | public String | getConfig() The configuration parameter used to initialize this MessageResources. | public MessageResourcesFactory | getFactory() The MessageResourcesFactory that created this instance. | public String | getMessage(String key) Returns a text message for the specified key, for the default Locale. | public String | getMessage(String key, Object[] args) Returns a text message after parametric replacement of the specified
parameter placeholders. | public String | getMessage(String key, Object arg0) Returns a text message after parametric replacement of the specified
parameter placeholders. | public String | getMessage(String key, Object arg0, Object arg1) Returns a text message after parametric replacement of the specified
parameter placeholders. | public String | getMessage(String key, Object arg0, Object arg1, Object arg2) Returns a text message after parametric replacement of the specified
parameter placeholders. | public String | getMessage(String key, Object arg0, Object arg1, Object arg2, Object arg3) Returns a text message after parametric replacement of the specified
parameter placeholders. | abstract public String | getMessage(Locale locale, String key) Returns a text message for the specified key, for the default Locale. | public String | getMessage(Locale locale, String key, Object[] args) Returns a text message after parametric replacement of the specified
parameter placeholders. | public String | getMessage(Locale locale, String key, Object arg0) Returns a text message after parametric replacement of the specified
parameter placeholders. | public String | getMessage(Locale locale, String key, Object arg0, Object arg1) Returns a text message after parametric replacement of the specified
parameter placeholders. | public String | getMessage(Locale locale, String key, Object arg0, Object arg1, Object arg2) Returns a text message after parametric replacement of the specified
parameter placeholders. | public String | getMessage(Locale locale, String key, Object arg0, Object arg1, Object arg2, Object arg3) Returns a text message after parametric replacement of the specified
parameter placeholders. | public static synchronized MessageResources | getMessageResources(String config) Create and return an instance of MessageResources for the
created by the default MessageResourcesFactory . | public boolean | getReturnNull() Indicates that a null is returned instead of an error
message string if an unknown Locale or key is requested. | public boolean | isEscape() Indicates whether 'escape processing' should be performed on the error
message string. | public boolean | isPresent(String key) Return true if there is a defined message for the
specified key in the system default locale. | public boolean | isPresent(Locale locale, String key) Return true if there is a defined message for the
specified key in the specified Locale. | protected String | localeKey(Locale locale) Compute and return a key to be used in caching information by a Locale. | public void | log(String message) Log a message to the Writer that has been configured for our use. | public void | log(String message, Throwable throwable) Log a message and exception to the Writer that has been configured for
our use. | protected String | messageKey(Locale locale, String key) Compute and return a key to be used in caching information by Locale
and message key. | protected String | messageKey(String localeKey, String key) Compute and return a key to be used in caching information by locale
key and message key. | public void | setEscape(boolean escape) Set whether 'escape processing' should be performed on the error
message string. | 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. |
config | protected String config(Code) | | The configuration parameter used to initialize this MessageResources.
|
defaultFactory | protected static MessageResourcesFactory defaultFactory(Code) | | The default MessageResourcesFactory used to create MessageResources
instances.
|
defaultLocale | protected Locale defaultLocale(Code) | | The default Locale for our environment.
|
formats | protected HashMap formats(Code) | | The set of previously created MessageFormat objects, keyed by the key
computed in messageKey() .
|
log | protected static Log log(Code) | | Commons Logging instance.
|
returnNull | protected boolean returnNull(Code) | | Indicate is a null is returned instead of an error message
string when an unknown Locale or key is requested.
|
MessageResources | public MessageResources(MessageResourcesFactory factory, String config)(Code) | | Construct a new MessageResources according to the specified
parameters.
Parameters: factory - The MessageResourcesFactory that created us Parameters: config - The configuration parameter for this MessageResources |
MessageResources | public MessageResources(MessageResourcesFactory factory, String config, boolean returnNull)(Code) | | Construct a new MessageResources according to the specified
parameters.
Parameters: factory - The MessageResourcesFactory that created us Parameters: config - The configuration parameter for thisMessageResources Parameters: returnNull - The returnNull property we should initialize with |
escape | protected String escape(String string)(Code) | | Escape any single quote characters that are included in the specified
message string.
Parameters: string - The string to be escaped |
getConfig | public String getConfig()(Code) | | The configuration parameter used to initialize this MessageResources.
parameter used to initialize this MessageResources |
getFactory | public MessageResourcesFactory getFactory()(Code) | | The MessageResourcesFactory that created this instance.
MessageResourcesFactory that created instance |
getMessage | public String getMessage(String key)(Code) | | Returns a text message for the specified key, for the default Locale.
Parameters: key - The message key to look up |
getMessage | public String getMessage(String key, Object[] args)(Code) | | Returns a text message after parametric replacement of the specified
parameter placeholders.
Parameters: key - The message key to look up Parameters: args - An array of replacement parameters for placeholders |
getMessage | public String getMessage(String key, Object arg0)(Code) | | Returns a text message after parametric replacement of the specified
parameter placeholders.
Parameters: key - The message key to look up Parameters: arg0 - The replacement for placeholder {0} in the message |
getMessage | public String getMessage(String key, Object arg0, Object arg1)(Code) | | Returns a text message after parametric replacement of the specified
parameter placeholders.
Parameters: key - The message key to look up Parameters: arg0 - The replacement for placeholder {0} in the message Parameters: arg1 - The replacement for placeholder {1} in the message |
getMessage | public String getMessage(String key, Object arg0, Object arg1, Object arg2)(Code) | | Returns a text message after parametric replacement of the specified
parameter placeholders.
Parameters: key - The message key to look up Parameters: arg0 - The replacement for placeholder {0} in the message Parameters: arg1 - The replacement for placeholder {1} in the message Parameters: arg2 - The replacement for placeholder {2} in the message |
getMessage | public String getMessage(String key, Object arg0, Object arg1, Object arg2, Object arg3)(Code) | | Returns a text message after parametric replacement of the specified
parameter placeholders.
Parameters: key - The message key to look up Parameters: arg0 - The replacement for placeholder {0} in the message Parameters: arg1 - The replacement for placeholder {1} in the message Parameters: arg2 - The replacement for placeholder {2} in the message Parameters: arg3 - The replacement for placeholder {3} in the message |
getMessage | abstract public String getMessage(Locale locale, String key)(Code) | | 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.
Parameters: locale - The requested message Locale, or null forthe system default Locale Parameters: key - The message key to look up |
getMessage | public String getMessage(Locale locale, String key, Object[] args)(Code) | | 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.
Parameters: locale - The requested message Locale, or null forthe system default Locale Parameters: key - The message key to look up Parameters: args - An array of replacement parameters for placeholders |
getMessage | public String getMessage(Locale locale, String key, Object arg0)(Code) | | Returns a text message after parametric replacement of the specified
parameter placeholders. A null string result will never be returned by
this method.
Parameters: locale - The requested message Locale, or null forthe system default Locale Parameters: key - The message key to look up Parameters: arg0 - The replacement for placeholder {0} in the message |
getMessage | public String getMessage(Locale locale, String key, Object arg0, Object arg1)(Code) | | Returns a text message after parametric replacement of the specified
parameter placeholders. A null string result will never be returned by
this method.
Parameters: locale - The requested message Locale, or null forthe system default Locale Parameters: key - The message key to look up Parameters: arg0 - The replacement for placeholder {0} in the message Parameters: arg1 - The replacement for placeholder {1} in the message |
getMessage | public String getMessage(Locale locale, String key, Object arg0, Object arg1, Object arg2)(Code) | | Returns a text message after parametric replacement of the specified
parameter placeholders. A null string result will never be returned by
this method.
Parameters: locale - The requested message Locale, or null forthe system default Locale Parameters: key - The message key to look up Parameters: arg0 - The replacement for placeholder {0} in the message Parameters: arg1 - The replacement for placeholder {1} in the message Parameters: arg2 - The replacement for placeholder {2} in the message |
getMessage | public String getMessage(Locale locale, String key, Object arg0, Object arg1, Object arg2, Object arg3)(Code) | | Returns a text message after parametric replacement of the specified
parameter placeholders. A null string result will never be returned by
this method.
Parameters: locale - The requested message Locale, or null forthe system default Locale Parameters: key - The message key to look up Parameters: arg0 - The replacement for placeholder {0} in the message Parameters: arg1 - The replacement for placeholder {1} in the message Parameters: arg2 - The replacement for placeholder {2} in the message Parameters: arg3 - The replacement for placeholder {3} in the message |
getMessageResources | public static synchronized MessageResources getMessageResources(String config)(Code) | | Create and return an instance of MessageResources for the
created by the default MessageResourcesFactory .
Parameters: config - Configuration parameter for this message bundle. |
getReturnNull | public boolean getReturnNull()(Code) | | 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 |
isEscape | public boolean isEscape()(Code) | | Indicates whether 'escape processing' should be performed on the error
message string.
since: Struts 1.2.8 |
isPresent | public boolean isPresent(String key)(Code) | | Return true if there is a defined message for the
specified key in the system default locale.
Parameters: key - The message key to look up |
isPresent | public boolean isPresent(Locale locale, String key)(Code) | | Return true if there is a defined message for the
specified key in the specified Locale.
Parameters: locale - The requested message Locale, or null forthe system default Locale Parameters: key - The message key to look up |
localeKey | protected String localeKey(Locale locale)(Code) | | 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.
Parameters: locale - The locale for which a key is desired |
log | public void log(String message)(Code) | | Log a message to the Writer that has been configured for our use.
Parameters: message - The message to be logged |
log | public void log(String message, Throwable throwable)(Code) | | Log a message and exception to the Writer that has been configured for
our use.
Parameters: message - The message to be logged Parameters: throwable - The exception to be logged |
messageKey | protected String messageKey(Locale locale, String key)(Code) | | Compute and return a key to be used in caching information by Locale
and message key.
Parameters: locale - The Locale for which this format key is calculated Parameters: key - The message key for which this format key is calculated |
messageKey | protected String messageKey(String localeKey, String key)(Code) | | Compute and return a key to be used in caching information by locale
key and message key.
Parameters: localeKey - The locale key for which this cache key is calculated Parameters: key - The message key for which this cache key iscalculated |
setEscape | public void setEscape(boolean escape)(Code) | | Set whether 'escape processing' should be performed on the error
message string.
since: Struts 1.2.8 |
setReturnNull | public void setReturnNull(boolean returnNull)(Code) | | Indicates that a null is returned instead of an error
message string if an unknown Locale or key is requested.
Parameters: returnNull - true Indicates that a null is returnedif an unknown Locale or key is requested. |
|
|