public class DefaultMessageContext extends java.lang.Object implements StateManageableMessageContext
MessageSource
to resolve messages that are added by
callers.Constructor and Description |
---|
DefaultMessageContext()
Creates a new default message context.
|
DefaultMessageContext(org.springframework.context.MessageSource messageSource)
Creates a new default message context.
|
Modifier and Type | Method and Description |
---|---|
void |
addMessage(MessageResolver messageResolver)
Add a new message to this context.
|
void |
clearMessages()
Clear all messages added to this context.
|
java.io.Serializable |
createMessagesMemento()
Create a serializable memento, or token representing a snapshot of the internal state of this message context.
|
Message[] |
getAllMessages()
Get all messages in this context.
|
Message[] |
getMessagesByCriteria(MessageCriteria criteria)
Get all messages that meet the given result criteria.
|
Message[] |
getMessagesBySource(java.lang.Object source)
Get all messages in this context for the source provided.
|
org.springframework.context.MessageSource |
getMessageSource() |
boolean |
hasErrorMessages()
Returns true if there are error messages in this context.
|
void |
restoreMessages(java.io.Serializable messagesMemento)
Set the state of this context from the memento provided.
|
void |
setMessageSource(org.springframework.context.MessageSource messageSource)
Configure the message source used to resolve messages added to this context.
|
java.lang.String |
toString() |
public DefaultMessageContext()
public DefaultMessageContext(org.springframework.context.MessageSource messageSource)
messageSource
- the message source to resolve messages added to this contextpublic org.springframework.context.MessageSource getMessageSource()
public Message[] getAllMessages()
MessageContext
getAllMessages
in interface MessageContext
public Message[] getMessagesBySource(java.lang.Object source)
MessageContext
getMessagesBySource
in interface MessageContext
source
- the source associated with messages, or null for global messagespublic Message[] getMessagesByCriteria(MessageCriteria criteria)
MessageContext
getMessagesByCriteria
in interface MessageContext
criteria
- the message criteriapublic boolean hasErrorMessages()
MessageContext
hasErrorMessages
in interface MessageContext
public void addMessage(MessageResolver messageResolver)
MessageContext
addMessage
in interface MessageContext
messageResolver
- the resolver that will resolve the message to be addedpublic void clearMessages()
MessageContext
clearMessages
in interface MessageContext
public java.io.Serializable createMessagesMemento()
StateManageableMessageContext
createMessagesMemento
in interface StateManageableMessageContext
public void restoreMessages(java.io.Serializable messagesMemento)
StateManageableMessageContext
restoreMessages
in interface StateManageableMessageContext
messagesMemento
- the messages mementopublic void setMessageSource(org.springframework.context.MessageSource messageSource)
StateManageableMessageContext
setMessageSource
in interface StateManageableMessageContext
messageSource
- the message sourceMessageContext.addMessage(MessageResolver)
public java.lang.String toString()
toString
in class java.lang.Object