|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.binding.message.MessageBuilder
public class MessageBuilder
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();
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 |
---|
public MessageBuilder()
Method Detail |
---|
public MessageBuilder info()
public MessageBuilder warning()
public MessageBuilder error()
public MessageBuilder fatal()
public MessageBuilder source(java.lang.Object source)
source
- the source to associate the message with
public MessageBuilder code(java.lang.String code)
code
- the message code
public MessageBuilder codes(java.lang.String[] codes)
codes
- the message codes; if null, no changes will be made
public MessageBuilder arg(java.lang.Object arg)
arg
- the message argument value
public MessageBuilder args(java.lang.Object[] args)
args
- the message argument values, if null no changes will be made
public MessageBuilder resolvableArg(java.lang.Object arg)
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.
arg
- the resolvable message argument
public MessageBuilder resolvableArgs(java.lang.Object[] args)
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.
args
- the resolvable message arguments
public MessageBuilder defaultText(java.lang.String text)
text
- the default text
public MessageResolver build()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |