|
[Deprecated API] | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | CURRENT API | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--com.interface21.context.support.AbstractNestingMessageSource
Abstract implementation of NestingMessageSource interface, making it
easy to implement custom MessageSources. Subclasses must implement the
abstract resolve() method.
This class does not currently implement caching, thus subclasses can
dynamically change messages over time.
NOTE: Some methods of this class are based on code from Struts 1.1b3 implementation.
| Constructor Summary | |
AbstractNestingMessageSource()
|
|
| Method Summary | |
protected java.lang.String |
escape(java.lang.String string)
Escape any single quote characters that are included in the specified message string. |
protected java.util.Locale |
getDefaultLocale()
|
java.lang.String |
getMessage(MessageSourceResolvable resolvable,
java.util.Locale locale)
Using all the attributes contained within the MessageSourceResolvable
arg that was passed in (except for the locale attribute),
try to resolve the message from the MessageSource contained within the Context.
NOTE: We must throw a NoSuchMessageException on this method since
at the time of calling this method we aren't able to determine if the defaultMessage
attribute is null or not. |
java.lang.String |
getMessage(java.lang.String code,
java.lang.Object[] args,
java.util.Locale locale)
Try to resolve the message. |
java.lang.String |
getMessage(java.lang.String code,
java.lang.Object[] args,
java.lang.String defaultMessage,
java.util.Locale locale)
Try to resolve the message.Return default message if no message was found |
protected java.lang.String |
localeKey(java.util.Locale locale)
Compute and return a key to be used in caching information by a Locale. |
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. |
protected abstract java.lang.String |
resolve(java.lang.String code,
java.util.Locale locale)
Subclasses must implement this method to resolve a message |
void |
setParent(MessageSource parent)
Set the parent that will be used to try to resolve messages that this object can't resolve. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public AbstractNestingMessageSource()
| Method Detail |
public final void setParent(MessageSource parent)
NestingMessageSourcesetParent in interface NestingMessageSourcecom.interface21.context.NestingMessageSourceparent - parent MessageSource that will be used to
resolve messages that this object can't resolve.
May be null, in which case no further resolution is possible.
public final java.lang.String getMessage(java.lang.String code,
java.lang.Object[] args,
java.lang.String defaultMessage,
java.util.Locale locale)
getMessage in interface MessageSourcecode - code to lookup up, such as 'calculator.noRateSet'locale - Locale in which to do lookupargs - Array of arguments that will be filled in for params within
the message (params look like "{0}", "{1,date}", "{2,time}" within a message).defaultMessage - String to return if the lookup fails
public java.lang.String getMessage(MessageSourceResolvable resolvable,
java.util.Locale locale)
throws NoSuchMessageException
MessageSourceResolvable
arg that was passed in (except for the locale attribute),
try to resolve the message from the MessageSource contained within the Context.
NOTE: We must throw a NoSuchMessageException on this method since
at the time of calling this method we aren't able to determine if the defaultMessage
attribute is null or not.
getMessage in interface MessageSourceresolvable - Value object storing 4 attributes required to properly resolve a message.locale - Locale to be used as the "driver" to figuring out what message to return.NoSuchMessageException - not found in any locale
public final java.lang.String getMessage(java.lang.String code,
java.lang.Object[] args,
java.util.Locale locale)
throws NoSuchMessageException
getMessage in interface MessageSourcecode - code to lookup up, such as 'calculator.noRateSet'locale - Locale in which to do lookupargs - Array of arguments that will be filled in for params within
the message (params look like "{0}", "{1,date}", "{2,time}" within a message).NoSuchMessageException - not found in any locale
protected abstract java.lang.String resolve(java.lang.String code,
java.util.Locale locale)
throws java.lang.Exception
code - code of the message to resolvelocale - locale to resolve the code for. Subclasses
are encouraged to support internationalization.java.lang.Exception - if there's an error resolving the message.
Note that failure to find a message for the code is not an error.protected java.util.Locale getDefaultLocale()
protected java.lang.String localeKey(java.util.Locale locale)
locale - The locale for which a key is desired
protected java.lang.String messageKey(java.util.Locale locale,
java.lang.String key)
locale - The Locale for which this format key is calculatedkey - The message key for which this format key is calculated
protected java.lang.String messageKey(java.lang.String localeKey,
java.lang.String key)
localeKey - The locale key for which this cache key is calculatedkey - The message key for which this cache key is calculatedprotected java.lang.String escape(java.lang.String string)
string - The string to be escaped
|
[Deprecated API] | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | CURRENT API | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||