ch.elca.el4j.services.i18n
Class RewritingMessageSource

java.lang.Object
  extended by ch.elca.el4j.services.i18n.RewritingMessageSource
All Implemented Interfaces:
MessageSource

public class RewritingMessageSource
extends Object
implements MessageSource

A MessageSource based on MessageRewriters.

Author:
Adrian Moos (AMS)
File-location:
RewritingMessageSource
Last check-in date:
2009-08-04 15:35:01 +0200 (Di, 04. Aug 2009) by swismer for revision 3883

Field Summary
protected  MessageRewriter.Rule[] m_additionalRules
          A list of additional rules to be used by every locale.
protected  String[] m_basenames
          The base names.
protected  Map<Locale,MessageRewriter> m_rewriters
          The already loaded rewriters.
protected static org.slf4j.Logger s_logger
          The logger.
 
Constructor Summary
RewritingMessageSource()
           
 
Method Summary
protected  String assembleFileName(String... parts)
          Assembles the filename consisting of the given parts, separated by '_'.
protected  MessageRewriter createRewriter(Locale loc)
          Creates a new MessageRewriter for the given locale.
 String getMessage(MessageSourceResolvable resolvable, Locale locale)
          
 String getMessage(String code, Object[] args, Locale locale)
          
 String getMessage(String code, Object[] args, String defaultMessage, Locale locale)
          
 void setAdditionalRules(MessageRewriter.Rule... rules)
          Sets m_additionalRules.
 void setBasenames(String... basenames)
          Like ResourceBundleMessageSource.setBasenames(String[]).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_basenames

protected String[] m_basenames
The base names. See setBasenames(String[])


m_additionalRules

protected MessageRewriter.Rule[] m_additionalRules
A list of additional rules to be used by every locale.


m_rewriters

protected Map<Locale,MessageRewriter> m_rewriters
The already loaded rewriters.


s_logger

protected static final org.slf4j.Logger s_logger
The logger. (duh!)

Constructor Detail

RewritingMessageSource

public RewritingMessageSource()
Method Detail

setBasenames

public void setBasenames(String... basenames)
Like ResourceBundleMessageSource.setBasenames(String[]).


setAdditionalRules

public void setAdditionalRules(MessageRewriter.Rule... rules)
Sets m_additionalRules.


assembleFileName

protected String assembleFileName(String... parts)
Assembles the filename consisting of the given parts, separated by '_'.

Parameters:
parts - the parts to assembles. A part may be null, in which case it is omitted.
Returns:
the assembled filename

createRewriter

protected MessageRewriter createRewriter(Locale loc)
Creates a new MessageRewriter for the given locale.

Parameters:
loc - .
Returns:
the MessageRewriter created

getMessage

public String getMessage(MessageSourceResolvable resolvable,
                         Locale locale)
                  throws NoSuchMessageException

Specified by:
getMessage in interface MessageSource
Throws:
NoSuchMessageException

getMessage

public String getMessage(String code,
                         Object[] args,
                         Locale locale)
                  throws NoSuchMessageException

Specified by:
getMessage in interface MessageSource
Throws:
NoSuchMessageException

getMessage

public String getMessage(String code,
                         Object[] args,
                         String defaultMessage,
                         Locale locale)

Specified by:
getMessage in interface MessageSource


Copyright © 2005-2011 ELCA. All Rights Reserved.