Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Web Flow
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.binding.message
Class MessageBuilder

    java.lang.Object
      org.springframework.binding.message.MessageBuilder

    public class MessageBuilder

extends java.lang.Object

A convenient builder for building `MessageResolver` objects programmatically. Often used by model code such as validation logic to conveniently record validation messages. Supports the production of message resolvers that hard-code their message text, as well as message resolvers that retrieve their text from a `message resource bundle`. Usage example:

`new MessageBuilder().error().source("field").code("mycode").arg(arg1).arg(arg2).defaultText("text").build();`

Author:
  Keith Donald, Jeremy Grelle

Constructor Summary
`MessageBuilder()`

Method Summary
`MessageBuilder` | `arg(java.lang.Object arg)` Records that the message being built has a variable argument.
`MessageBuilder` | `args(java.lang.Object[] args)` Records that the message being built has variable arguments.
`MessageResolver` | `build()` Builds the message that will be resolved.
`MessageBuilder` | `code(java.lang.String code)` Records that the message being built should try and resolve its text using the code provided.
`MessageBuilder` | `codes(java.lang.String[] codes)` Records that the message being built should try and resolve its text using the codes provided.
`MessageBuilder` | `defaultText(java.lang.String text)` Records the fallback text of the message being built.
`MessageBuilder` | `error()` Records that the message being built is an error message.
`MessageBuilder` | `fatal()` Records that the message being built is a fatal message.
`MessageBuilder` | `info()` Records that the message being built is an informational message.
`MessageBuilder` | `resolvableArg(java.lang.Object arg)` Records that the message being built has a variable argument, whose display value is also `MessageSourceResolvable`.
`MessageBuilder` | `resolvableArgs(java.lang.Object[] args)` Records that the message being built has variable arguments, whose display values are also `MessageSourceResolvable` instances.
`MessageBuilder` | `source(java.lang.Object source)` Records that the message being built is against the provided source.
`MessageBuilder` | `warning()` Records that the message being built is a warning message.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### MessageBuilder

    public MessageBuilder()

Method Detail

### info

    public MessageBuilder info()

  Records that the message being built is an informational message.

  Returns:
    this, for fluent API usage

### warning

    public MessageBuilder warning()

  Records that the message being built is a warning message.

  Returns:
    this, for fluent API usage

### error

    public MessageBuilder error()

  Records that the message being built is an error message.

  Returns:
    this, for fluent API usage

### fatal

    public MessageBuilder fatal()

  Records that the message being built is a fatal message.

  Returns:
    this, for fluent API usage

### source

    public MessageBuilder source(java.lang.Object source)

  Records that the message being built is against the provided source.

  Parameters:
    `source` - the source to associate the message with
  Returns:
    this, for fluent API usage

### code

    public MessageBuilder code(java.lang.String code)

  Records that the message being built should try and resolve its text using the code provided. Adds the code to the codes list. Successive calls to this method add additional codes. Codes are applied in the order they are added.

  Parameters:
    `code` - the message code
  Returns:
    this, for fluent API usage

### codes

    public MessageBuilder codes(java.lang.String[] codes)

  Records that the message being built should try and resolve its text using the codes provided. Adds the codes to the codes list. Successive calls to this method add additional codes. Codes are applied in the order they are added.

  Parameters:
    `codes` - the message codes; if null, no changes will be made
  Returns:
    this, for fluent API usage

### arg

    public MessageBuilder arg(java.lang.Object arg)

  Records that the message being built has a variable argument. Adds the arg to the args list. Successive calls to this method add additional args. Args are applied in the order they are added.

  Parameters:
    `arg` - the message argument value
  Returns:
    this, for fluent API usage

### args

    public MessageBuilder args(java.lang.Object[] args)

  Records that the message being built has variable arguments. Adds the args to the args list. Successive calls to this method add additional args. Args are applied in the order they are added.

  Parameters:
    `args` - the message argument values, if null no changes will be made
  Returns:
    this, for fluent API usage

### resolvableArg

    public MessageBuilder resolvableArg(java.lang.Object arg)

  Records that the message being built has a variable argument, whose display value is also `MessageSourceResolvable`. Adds the arg to the args list. Successive calls to this method add additional resolvable args. Args are applied in the order they are added.

  Parameters:
    `arg` - the resolvable message argument
  Returns:
    this, for fluent API usage

### resolvableArgs

    public MessageBuilder resolvableArgs(java.lang.Object[] args)

  Records that the message being built has variable arguments, whose display values are also `MessageSourceResolvable` instances. Adds the args to the args list. Successive calls to this method add additional resolvable args. Args are applied in the order they are added.

  Parameters:
    `args` - the resolvable message arguments
  Returns:
    this, for fluent API usage

### defaultText

    public MessageBuilder defaultText(java.lang.String text)

  Records the fallback text of the message being built. If the message has no codes, this will always be used as the text. If the message has codes but none can be resolved, this will always be used as the text.

  Parameters:
    `text` - the default text
  Returns:
    this, for fluent API usage

### build

    public MessageResolver build()

  Builds the message that will be resolved. Called after the end of recording builder instructions.

  Returns:
    the built message resolver

Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Web Flow
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD