nl.knowlogy.validation
Class MessagesImpl

java.lang.Object
  extended by nl.knowlogy.validation.MessagesImpl
All Implemented Interfaces:
Messages

public class MessagesImpl
extends Object
implements Messages

Author:
Robert Hofstra, Knowlogy
See Also:
Messages

Constructor Summary
MessagesImpl()
           
 
Method Summary
 void add(Message message)
           
 void addMessage(Message message)
          Stores an message in the messages.
 void addMessage(MessageType messageType, Object object, String errorCode)
           Stores and creates an Message in the messages, based on the give params.
 void addMessage(MessageType messageType, Object object, String errorCode, Object[] errorArgs, String errorMessage)
          Add a message.
 void addMessage(MessageType messageType, Object object, String errorCode, String defaultMessage)
          Add a message.
 void addMessages(Messages messages)
          Adds messages.
 void addPropertyMessage(MessageType messageType, Object object, String propertyName, String errorCode)
          Add a message for a specific property of the object.
 void addPropertyMessage(MessageType messageType, Object object, String propertyName, String errorCode, Object[] errorArgs, String errorMessage)
          Add a message for a specific property of the object.
 void addPropertyMessage(MessageType messageType, Object object, String propertyName, String errorCode, String errorMessage)
          Add a message for a specific property of the object.
 void clear()
          Clears all messages in the container.
 void convertMessageCodes(ResourceBundle resourceBundle)
           
 Message get(int index)
           
 String getMessage()
          Returns an overal messageMessage.
 Message getMessage(Object object, boolean objectLevelOnly)
           
 Message getMessage(Object object, String propertyName)
          Returns the first message associated with the given object and propertyName, if such a message is present else null.
 List getMessages()
           
 List getMessages(Object object, boolean objectLevelOnly)
           
 List getMessages(Object object, String propertyName)
          Returns a list of Message instances associated with the given object and propertyName, if such a message is present.
 int getNumberOfErrorMessages()
           
 int getNumberOfMessages()
          Returns the number of message's.
 int getNumberOfMessages(MessageType messageType)
          Returns the number of messages with a specific messagetype.
 Message getObjectMessage(Object object)
           
 Message getObjectMessage(Object object, boolean objectLevelOnly)
           
 Message getObjectMessage(Object object, String fieldName)
           
 boolean hasErrors()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MessagesImpl

public MessagesImpl()
Method Detail

addMessage

public void addMessage(Message message)
Description copied from interface: Messages
Stores an message in the messages.

Specified by:
addMessage in interface Messages
Parameters:
message - message to add

addMessage

public void addMessage(MessageType messageType,
                       Object object,
                       String errorCode)
Description copied from interface: Messages

Stores and creates an Message in the messages, based on the give params.

These messages are not bound to a specific property of the object.

Specified by:
addMessage in interface Messages
Parameters:
messageType - type of the message
object - the rejected object
errorCode - message code, interpretable as message key

addMessage

public void addMessage(MessageType messageType,
                       Object object,
                       String errorCode,
                       Object[] errorArgs,
                       String errorMessage)
Description copied from interface: Messages
Add a message.

Specified by:
addMessage in interface Messages
Parameters:
messageType - type of the message
errorCode - message code, interpretable as message key
errorArgs - message arguments, for argument binding via MessageFormat (can be null)
errorMessage - fallback default message

addMessage

public void addMessage(MessageType messageType,
                       Object object,
                       String errorCode,
                       String defaultMessage)
Description copied from interface: Messages
Add a message.

Specified by:
addMessage in interface Messages
Parameters:
messageType - type of the message
errorCode - message code, interpretable as message key
defaultMessage - fallback default message

addPropertyMessage

public void addPropertyMessage(MessageType messageType,
                               Object object,
                               String propertyName,
                               String errorCode)
Description copied from interface: Messages
Add a message for a specific property of the object.

Specified by:
addPropertyMessage in interface Messages
Parameters:
messageType - type of the message
propertyName - the property name
errorCode - message code, interpretable as message key

addPropertyMessage

public void addPropertyMessage(MessageType messageType,
                               Object object,
                               String propertyName,
                               String errorCode,
                               String errorMessage)
Description copied from interface: Messages
Add a message for a specific property of the object.

Specified by:
addPropertyMessage in interface Messages
Parameters:
messageType - type of the message
propertyName - the field name
errorCode - message code, interpretable as message key
errorMessage - fallback default message

addPropertyMessage

public void addPropertyMessage(MessageType messageType,
                               Object object,
                               String propertyName,
                               String errorCode,
                               Object[] errorArgs,
                               String errorMessage)
Description copied from interface: Messages
Add a message for a specific property of the object.

Specified by:
addPropertyMessage in interface Messages
Parameters:
messageType - type of the message
propertyName - the property name
errorCode - message code, interpretable as message key
errorArgs - message arguments, for argument binding via MessageFormat (can be null)
errorMessage - fallback default message

toString

public String toString()
Overrides:
toString in class Object

getMessages

public List getMessages()
Specified by:
getMessages in interface Messages

addMessages

public void addMessages(Messages messages)
Description copied from interface: Messages
Adds messages.

Specified by:
addMessages in interface Messages

getNumberOfErrorMessages

public int getNumberOfErrorMessages()
Specified by:
getNumberOfErrorMessages in interface Messages

convertMessageCodes

public void convertMessageCodes(ResourceBundle resourceBundle)
Specified by:
convertMessageCodes in interface Messages

hasErrors

public boolean hasErrors()

getObjectMessage

public Message getObjectMessage(Object object,
                                String fieldName)

getObjectMessage

public Message getObjectMessage(Object object)

getObjectMessage

public Message getObjectMessage(Object object,
                                boolean objectLevelOnly)

add

public void add(Message message)

getNumberOfMessages

public int getNumberOfMessages()
Description copied from interface: Messages
Returns the number of message's.

Specified by:
getNumberOfMessages in interface Messages
Returns:

get

public Message get(int index)

getMessage

public Message getMessage(Object object,
                          String propertyName)
Description copied from interface: Messages
Returns the first message associated with the given object and propertyName, if such a message is present else null.

Specified by:
getMessage in interface Messages
Parameters:
object - object that is associated with the message.
propertyName - that is associated with the message.
Returns:
Returns the first message associated with the given object and propertyName, if such a message is present else null.

getMessages

public List getMessages(Object object,
                        String propertyName)
Description copied from interface: Messages
Returns a list of Message instances associated with the given object and propertyName, if such a message is present.

Specified by:
getMessages in interface Messages
Parameters:
object - object that is associated with the message.
propertyName - that is associated with the message.
Returns:
a list of Messageinstances associated with the given object and propertyName, if such a message is present.

getMessage

public Message getMessage(Object object,
                          boolean objectLevelOnly)
Specified by:
getMessage in interface Messages

getMessages

public List getMessages(Object object,
                        boolean objectLevelOnly)
Specified by:
getMessages in interface Messages

getMessage

public String getMessage()
Description copied from interface: Messages
Returns an overal messageMessage.

Specified by:
getMessage in interface Messages
Returns:

getNumberOfMessages

public int getNumberOfMessages(MessageType messageType)
Description copied from interface: Messages
Returns the number of messages with a specific messagetype.

Specified by:
getNumberOfMessages in interface Messages
Returns:

clear

public void clear()
Description copied from interface: Messages
Clears all messages in the container.

Specified by:
clear in interface Messages


Copyright © 2007. All Rights Reserved.