Package org.codehaus.groovy.tools.shell.util

# Class MessageSource

java.lang.Object
groovy.lang.GroovyObjectSupport
org.codehaus.groovy.tools.shell.util.MessageSource

All Implemented Interfaces:
  `GroovyObject`

public class MessageSource extends GroovyObjectSupport
Message source backed up by one or more `ResourceBundle` instances for simple i18n support.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MessageSource(Class type)`
  Creates a message source backed by the bundle named after the supplied type.
  `MessageSource(Class[] types)`
  Creates a message source backed by bundles named after the supplied types.
  `MessageSource(String name)`
  Creates a message source backed by a single named resource bundle.
  `MessageSource(String[] names)`
  Creates a message source backed by the named resource bundles.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `format(String code, 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.
  `String`
  `getMessage(String code)`
  Get a raw message from the resource bundles using the given code.
  `Object`
  `getProperty(String name)`
  Retrieves a property value.

  ### Methods inherited from class groovy.lang.GroovyObjectSupport

  `getMetaClass, setMetaClass`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface groovy.lang.GroovyObject

  `invokeMethod, setProperty`

- ## Constructor Details

  - ### MessageSource

    public MessageSource(String[] names)
    Creates a message source backed by the named resource bundles.
    Parameters:
      `names` - the bundle base names to search

  - ### MessageSource

    public MessageSource(String name)
    Creates a message source backed by a single named resource bundle.
    Parameters:
      `name` - the bundle base name

  - ### MessageSource

    public MessageSource(Class[] types)
    Creates a message source backed by bundles named after the supplied types.
    Parameters:
      `types` - the types whose names identify resource bundles

  - ### MessageSource

    public MessageSource(Class type)
    Creates a message source backed by the bundle named after the supplied type.
    Parameters:
      `type` - the type whose name identifies a resource bundle

- ## Method Details

  - ### getMessage

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

  - ### format

    public String format(String code, 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 Object getProperty(String name)
    Description copied from interface: `GroovyObject`
    Retrieves a property value.
    Parameters:
      `name` - the name of the property of interest
    Returns:
      the given property
    See Also:
      - `getMessage(String)`