org.openmrs.messagesource.impl
Class CachedMessageSource

java.lang.Object
  extended by org.springframework.context.support.MessageSourceSupport
      extended by org.springframework.context.support.AbstractMessageSource
          extended by org.openmrs.messagesource.impl.CachedMessageSource
All Implemented Interfaces:
MutableMessageSource, org.springframework.context.HierarchicalMessageSource, org.springframework.context.MessageSource

public class CachedMessageSource
extends org.springframework.context.support.AbstractMessageSource
implements MutableMessageSource

A MutableMessageSource backed by a localized map of PresentationMessageCollections, providing in-memory storage of PresentationMessages. Useful for temporary storage, as a cache for other sources, and for testing.


Field Summary
 
Fields inherited from class org.springframework.context.support.MessageSourceSupport
logger
 
Constructor Summary
CachedMessageSource()
           
 
Method Summary
 void addPresentation(PresentationMessage message)
          Adds a presentation message to the source.
 java.util.Collection<java.util.Locale> getLocales()
          Gets the locales for which messages are available from this source.
 PresentationMessage getPresentation(java.lang.String key, java.util.Locale forLocale)
          Gets the PresentationMessage for a particular locale.
 java.util.Collection<PresentationMessage> getPresentations()
          Gets all of the available messages, packaged as PresentationMessages.
 java.util.Collection<PresentationMessage> getPresentationsInLocale(java.util.Locale locale)
          Gets alll the available messages in a particular locale, packaged as PresentationMessages.
 void merge(MutableMessageSource fromSource, boolean overwrite)
          Merge messages from another source into this source.
 void publishProperties(java.util.Properties arg0, java.lang.String arg1, java.lang.String arg2, java.lang.String arg3, java.lang.String arg4)
          Deprecated. use merge(MutableMessageSource, boolean)
 void removePresentation(PresentationMessage message)
          Removes a presentation message from the source.
protected  java.text.MessageFormat resolveCode(java.lang.String code, java.util.Locale locale)
           
 
Methods inherited from class org.springframework.context.support.AbstractMessageSource
getDefaultMessage, getMessage, getMessage, getMessage, getMessageFromParent, getMessageInternal, getParentMessageSource, isUseCodeAsDefaultMessage, renderDefaultMessage, resolveArguments, resolveCodeWithoutArguments, setParentMessageSource, setUseCodeAsDefaultMessage
 
Methods inherited from class org.springframework.context.support.MessageSourceSupport
createMessageFormat, formatMessage, isAlwaysUseMessageFormat, setAlwaysUseMessageFormat
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.context.HierarchicalMessageSource
getParentMessageSource, setParentMessageSource
 
Methods inherited from interface org.springframework.context.MessageSource
getMessage, getMessage, getMessage
 

Constructor Detail

CachedMessageSource

public CachedMessageSource()
Method Detail

addPresentation

public void addPresentation(PresentationMessage message)
Description copied from interface: MutableMessageSource
Adds a presentation message to the source. This operation should overwrite any existing message which conflicts (has the same code and locale).

Specified by:
addPresentation in interface MutableMessageSource
Parameters:
message - message to add to the source

getLocales

public java.util.Collection<java.util.Locale> getLocales()
Description copied from interface: MutableMessageSource
Gets the locales for which messages are available from this source.

Specified by:
getLocales in interface MutableMessageSource
Returns:
available message locales
See Also:
MutableMessageSource.getLocales()
Expected behavior:
should be able to contain multiple locales

getPresentations

public java.util.Collection<PresentationMessage> getPresentations()
Description copied from interface: MutableMessageSource
Gets all of the available messages, packaged as PresentationMessages.

Specified by:
getPresentations in interface MutableMessageSource
Returns:
collection of presentation messages

publishProperties

public void publishProperties(java.util.Properties arg0,
                              java.lang.String arg1,
                              java.lang.String arg2,
                              java.lang.String arg3,
                              java.lang.String arg4)
Deprecated. use merge(MutableMessageSource, boolean)

Description copied from interface: MutableMessageSource
Makes a collection of properties available as messages.

Specified by:
publishProperties in interface MutableMessageSource
Parameters:
arg0 - key/value properties for the messages
arg1 - locale in which the messages are expressed
arg2 - namespace within which the properties are valid ("" for generic, "module" for modules, etc)
arg3 - unique name for the properties within the namespace
arg4 - version of the properties
See Also:
MutableMessageSource.publishProperties(java.util.Properties, java.lang.String, java.lang.String, java.lang.String, java.lang.String)

removePresentation

public void removePresentation(PresentationMessage message)
Description copied from interface: MutableMessageSource
Removes a presentation message from the source.

Specified by:
removePresentation in interface MutableMessageSource
Parameters:
message - the message to remove

merge

public void merge(MutableMessageSource fromSource,
                  boolean overwrite)
Description copied from interface: MutableMessageSource
Merge messages from another source into this source.

Specified by:
merge in interface MutableMessageSource
Parameters:
fromSource - message source from which messages should be merge
overwrite - whether to overwrite existing messages

getPresentation

public PresentationMessage getPresentation(java.lang.String key,
                                           java.util.Locale forLocale)
Description copied from interface: MutableMessageSource
Gets the PresentationMessage for a particular locale.

Specified by:
getPresentation in interface MutableMessageSource
Parameters:
key - textual key for the message
forLocale - locale for which to get the message
Returns:
corresponding PresentationMessage, or null if not available
See Also:
MutableMessageSource.getPresentation(java.lang.String, java.util.Locale)
Expected behavior:
match get message with presentation message

getPresentationsInLocale

public java.util.Collection<PresentationMessage> getPresentationsInLocale(java.util.Locale locale)
Description copied from interface: MutableMessageSource
Gets alll the available messages in a particular locale, packaged as PresentationMessages.

Specified by:
getPresentationsInLocale in interface MutableMessageSource
Parameters:
locale - locale for which to get the messages
Returns:
collection of PresentationMessages in the locale
See Also:
MutableMessageSource.getPresentationsInLocale(java.util.Locale)

resolveCode

protected java.text.MessageFormat resolveCode(java.lang.String code,
                                              java.util.Locale locale)
Specified by:
resolveCode in class org.springframework.context.support.AbstractMessageSource
See Also:
AbstractMessageSource.resolveCode(java.lang.String, java.util.Locale)

OpenMRS-1.7.x

Generated Apr 27 2012 10:06 PM. NOTE - these libraries are in active development and subject to change