org.sonatype.sisu.goodies.i18n
Class ResourceBundleMessageSource

java.lang.Object
  extended by org.sonatype.sisu.goodies.common.ComponentSupport
      extended by org.sonatype.sisu.goodies.i18n.ResourceBundleMessageSource
All Implemented Interfaces:
MessageSource

public class ResourceBundleMessageSource
extends ComponentSupport
implements MessageSource

Message source backed up by ResourceBundle instances.

Since:
1.0

Field Summary
 
Fields inherited from class org.sonatype.sisu.goodies.common.ComponentSupport
log
 
Constructor Summary
ResourceBundleMessageSource(Class... types)
           
ResourceBundleMessageSource(Locale locale)
           
 
Method Summary
 ResourceBundleMessageSource add(boolean required, Class... types)
           
 ResourceBundleMessageSource add(Class... types)
           
 String format(String code, Object... args)
          Format a message (based on String.format(java.lang.String, java.lang.Object...) using the message from the resource bundles using the given code as a pattern and the given objects as arguments.
 Locale getLocale()
           
 String getMessage(String code)
          Get a raw message from the resource bundles using the given code.
 String getMessage(String code, String defaultValue)
           
 
Methods inherited from class org.sonatype.sisu.goodies.common.ComponentSupport
createLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceBundleMessageSource

public ResourceBundleMessageSource(Locale locale)

ResourceBundleMessageSource

public ResourceBundleMessageSource(Class... types)
Method Detail

getLocale

public Locale getLocale()

add

public ResourceBundleMessageSource add(boolean required,
                                       Class... types)

add

public ResourceBundleMessageSource add(Class... types)

getMessage

public String getMessage(String code)
Get a raw message from the resource bundles using the given code.

Specified by:
getMessage in interface MessageSource

getMessage

public String getMessage(String code,
                         String defaultValue)
Specified by:
getMessage in interface MessageSource

format

public String format(String code,
                     @Nullable
                     Object... args)
Format a message (based on String.format(java.lang.String, java.lang.Object...) using the message from the resource bundles using the given code as a pattern and the given objects as arguments.

Specified by:
format in interface MessageSource


Copyright © 2008-2012 Sonatype, Inc.. All Rights Reserved.