org.codehaus.groovy.tools.shell.util
Class MessageSource

java.lang.Object
  extended by groovy.lang.GroovyObjectSupport
      extended by org.codehaus.groovy.tools.shell.util.MessageSource
All Implemented Interfaces:
GroovyObject
Direct Known Subclasses:
ANSI.RenderMessageSource

public class MessageSource
extends GroovyObjectSupport

Message source backed up by one or more ResourceBundle instances for simple i18n support.

Version:
$Id: MessageSource.java 7767 2007-08-27 19:47:34Z user57 $
Author:
Jason Dillon

Field Summary
private  java.lang.String[] bundleNames
           
private  java.util.ResourceBundle[] cachedBundles
           
 
Constructor Summary
MessageSource(java.lang.Class type)
           
MessageSource(java.lang.Class[] types)
           
MessageSource(java.lang.String name)
           
MessageSource(java.lang.String[] names)
           
 
Method Summary
private static java.lang.String[] classNames(java.lang.Class[] types)
           
private  java.util.ResourceBundle[] createBundles()
           
 java.lang.String format(java.lang.String code, java.lang.Object[] args)
          Format a message (based on MessageFormat using the message from the resource bundles using the given code as a pattern and the given objects as arguments.
private  java.util.ResourceBundle[] getBundles()
           
 java.lang.String getMessage(java.lang.String code)
          Get a raw message from the resource bundles using the given code.
 java.lang.Object getProperty(java.lang.String name)
          Retrieves a property value.
 
Methods inherited from class groovy.lang.GroovyObjectSupport
getMetaClass, invokeMethod, setMetaClass, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bundleNames

private final java.lang.String[] bundleNames

cachedBundles

private java.util.ResourceBundle[] cachedBundles
Constructor Detail

MessageSource

public MessageSource(java.lang.String[] names)

MessageSource

public MessageSource(java.lang.String name)

MessageSource

public MessageSource(java.lang.Class[] types)

MessageSource

public MessageSource(java.lang.Class type)
Method Detail

classNames

private static java.lang.String[] classNames(java.lang.Class[] types)

createBundles

private java.util.ResourceBundle[] createBundles()

getBundles

private java.util.ResourceBundle[] getBundles()

getMessage

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


format

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


getProperty

public java.lang.Object getProperty(java.lang.String name)
Description copied from interface: GroovyObject
Retrieves a property value.

Specified by:
getProperty in interface GroovyObject
Overrides:
getProperty in class GroovyObjectSupport
Parameters:
name - the name of the property of interest
Returns:
the given property
See Also:
getMessage(String)


Copyright © ${year} The Codehaus. All Rights Reserved.