org.faktorips.runtime
Class MessageList

java.lang.Object
  extended by org.faktorips.runtime.MessageList
All Implemented Interfaces:
Serializable, Iterable<Message>

public class MessageList
extends Object
implements Serializable, Iterable<Message>

A list of Messages.

Author:
Jan Ortmann
See Also:
Message, Serialized Form

Constructor Summary
MessageList()
          Creates an empty message list.
MessageList(Message msg)
          Creates a message list that contains the given message.
 
Method Summary
 void add(Message msg)
          Adds the message to the list.
 void add(MessageList msgList)
          Adds the messages in the given list to this list.
 void add(MessageList msgList, ObjectProperty invalidObjectProperty, boolean override)
          Copies the messages from the given list to this list and sets the message's invalid object properties.
 void clear()
          Removes all of the messages from this list.
 boolean containsErrorMsg()
          Returns true if one the messages in the list is an error message, otherwise false.
static MessageList createCopy(MessageList list, Object oldObject, Object newObject)
          Creates a copy from the message list and replaces all references to the old object with the new object.
 boolean equals(Object obj)
           
 Message getFirstMessage(Severity severity)
          Returns the first message with the given severity or null if none is found.
 Message getMessage(int index)
          Returns the message at the indicated index (indexing starts with 0).
 Message getMessageByCode(String code)
          Returns the first message in the list that has the specified message code.
 MessageList getMessagesByCode(String code)
          Returns a new message list containing all the message in this list that have the specified message code.
 MessageList getMessagesFor(Object object)
          Returns a new list with the messages in this list that belong to the given object (any property).
 MessageList getMessagesFor(Object object, String property)
          Returns a new list with the messages in this list that belong to the given object and property.
 MessageList getMessagesFor(Object object, String property, int index)
          Returns a new list with the messages in this list that belong to the given object and property and the property is of the given index.
 int getNoOfMessages()
          Deprecated. use #size() instead
 Severity getSeverity()
          Returns the message list's severity.
 String getText()
          Returns the text of all messages in the list, separated by the system's default line separator.
 int hashCode()
           
 boolean isEmpty()
          Returns true if the list is empty.
 Iterator<Message> iterator()
          Returns an iterator over the messages in this list.
 int size()
          Returns the number of messages in the list.
 String toString()
          Returns all messages in the list separated by a line separator.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MessageList

public MessageList()
Creates an empty message list.


MessageList

public MessageList(Message msg)
Creates a message list that contains the given message.

Throws:
IllegalArgumentException - if msg is null.
Method Detail

createCopy

public static final MessageList createCopy(MessageList list,
                                           Object oldObject,
                                           Object newObject)
Creates a copy from the message list and replaces all references to the old object with the new object.

Parameters:
list - the list to copy
oldObject - the old object reference that should be replaced.
newObject - the object reference to set

add

public void add(Message msg)
Adds the message to the list.

Throws:
NullPointerException - if msg is null.

add

public void add(MessageList msgList)
Adds the messages in the given list to this list.

Throws:
IllegalArgumentException - if msgList is null.

add

public void add(MessageList msgList,
                ObjectProperty invalidObjectProperty,
                boolean override)
Copies the messages from the given list to this list and sets the message's invalid object properties.

Parameters:
msgList - the list to copy the messages from.
invalidObjectProperty - the object and it's property that the messages refer to.
override - true if the invalidObjectProperty should be set in all messages. false if the invalidObjectProperty is set only for messages that do not contain any invalid object property information.

isEmpty

public boolean isEmpty()
Returns true if the list is empty.


getNoOfMessages

@Deprecated
public int getNoOfMessages()
Deprecated. use #size() instead

Returns the number of messages in the list.


size

public int size()
Returns the number of messages in the list.

Returns:
The size of the message list

getMessage

public Message getMessage(int index)
Returns the message at the indicated index (indexing starts with 0).

Throws:
IndexOutOfBoundsException - if the index is out of range.

getFirstMessage

public Message getFirstMessage(Severity severity)
Returns the first message with the given severity or null if none is found.


getMessageByCode

public Message getMessageByCode(String code)
Returns the first message in the list that has the specified message code. Returns null, if the list does not contain such a message.


getMessagesByCode

public MessageList getMessagesByCode(String code)
Returns a new message list containing all the message in this list that have the specified message code. Returns an empty list if either code is null or this list does contain any message with the given code.


getSeverity

public Severity getSeverity()
Returns the message list's severity. This is the maximum severity of the list's messages. If the list does not contain any messages, the method returns 0.


getText

public String getText()
Returns the text of all messages in the list, separated by the system's default line separator.


containsErrorMsg

public boolean containsErrorMsg()
Returns true if one the messages in the list is an error message, otherwise false.


getMessagesFor

public MessageList getMessagesFor(Object object)
Returns a new list with the messages in this list that belong to the given object (any property). Returns an empty list if no such message is found.


getMessagesFor

public MessageList getMessagesFor(Object object,
                                  String property,
                                  int index)
Returns a new list with the messages in this list that belong to the given object and property and the property is of the given index. Returns an empty list if no such message is found.


getMessagesFor

public MessageList getMessagesFor(Object object,
                                  String property)
Returns a new list with the messages in this list that belong to the given object and property. Returns an empty list if no such message is found.


iterator

public Iterator<Message> iterator()
Returns an iterator over the messages in this list.

Specified by:
iterator in interface Iterable<Message>

clear

public void clear()
Removes all of the messages from this list. This list will be empty after this call returns.


toString

public String toString()
Returns all messages in the list separated by a line separator. Overridden method.

Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


Copyright © 2015. All rights reserved.