org.apache.commons.scaffold.util
Class MessagesImpl

java.lang.Object
  extended by org.apache.commons.scaffold.util.MessagesImpl
All Implemented Interfaces:
Serializable, Messages

public class MessagesImpl
extends Object
implements Serializable, Messages

See Also:
Serialized Form

Nested Class Summary
protected  class MessagesImpl.MessageItem
           
 
Field Summary
protected  int iCount
          The current number of the property/key being added.
protected  HashMap messages
          The accumulated set of Message objects (represented as an ArrayList) for each property, keyed by property name.
 
Fields inherited from interface org.apache.commons.scaffold.util.Messages
GLOBAL_MESSAGE_KEY
 
Constructor Summary
MessagesImpl()
          Create an empty Messages object.
MessagesImpl(Messages messages)
          Create an AMessages object initialized with the given messages.
 
Method Summary
 void add(Message message)
          Add a message to the set of messages for the "global" property.
 void add(Messages messages)
          Adds the messages from the given Messages object to this set of messages.
 void add(String property, Message message)
          Add a message to the set of messages for the specified property.
 void clear()
          Clear all messages recorded by this object.
 boolean empty()
          Return true if there are no messages recorded in this collection, or false otherwise.
 Iterator get()
          Return the set of all recorded messages, without distinction by which property the messages are associated with.
 Iterator get(String property)
          Return the set of messages related to a specific property.
 boolean isEmpty()
          Return true if there are no messages recorded in this collection, or false otherwise.
 Iterator properties()
          Return the set of property names for which at least one message has been recorded.
 int size()
          Return the number of messages recorded for all properties (including global messages).
 int size(String property)
          Return the number of messages associated with the specified property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

messages

protected HashMap messages
The accumulated set of Message objects (represented as an ArrayList) for each property, keyed by property name.


iCount

protected int iCount
The current number of the property/key being added. This is used to maintain the order messages are added.

Constructor Detail

MessagesImpl

public MessagesImpl()
Create an empty Messages object.


MessagesImpl

public MessagesImpl(Messages messages)
Create an AMessages object initialized with the given messages.

Parameters:
messages - The messages to be initially added to this object.
Since:
Struts 1.1
Method Detail

add

public void add(String property,
                Message message)
Description copied from interface: Messages
Add a message to the set of messages for the specified property. An order of the property/key is maintained based on the initial addition of the property/key.

Specified by:
add in interface Messages
Parameters:
property - Property name (or Messages.GLOBAL_MESSAGE_KEY)
message - The message to be added

add

public void add(Message message)
Description copied from interface: Messages
Add a message to the set of messages for the "global" property. An order of the property/key is maintained based on the initial addition of the property/key.

Specified by:
add in interface Messages
Parameters:
message - The message to be added

add

public void add(Messages messages)
Description copied from interface: Messages
Adds the messages from the given Messages object to this set of messages. The messages are added in the order they are returned from the properties() method. If a message's property is already in the current Messages object it is added to the end of the list for that property. If a message's property is not in the current list it is added to the end of the properties.

Specified by:
add in interface Messages
Parameters:
messages - The Messages object to be added.

clear

public void clear()
Description copied from interface: Messages
Clear all messages recorded by this object.

Specified by:
clear in interface Messages

empty

public boolean empty()
Description copied from interface: Messages
Return true if there are no messages recorded in this collection, or false otherwise.

Specified by:
empty in interface Messages

isEmpty

public boolean isEmpty()
Description copied from interface: Messages
Return true if there are no messages recorded in this collection, or false otherwise.

Specified by:
isEmpty in interface Messages

get

public Iterator get()
Description copied from interface: Messages
Return the set of all recorded messages, without distinction by which property the messages are associated with. If there are no messages recorded, an empty enumeration is returned.

Specified by:
get in interface Messages

get

public Iterator get(String property)
Description copied from interface: Messages
Return the set of messages related to a specific property. If there are no such messages, an empty enumeration is returned.

Specified by:
get in interface Messages
Parameters:
property - Property name (or ActionMessages.GLOBAL_MESSAGE_KEY)

properties

public Iterator properties()
Description copied from interface: Messages
Return the set of property names for which at least one message has been recorded. If there are no messages, an empty Iterator is returned. If you have recorded global messages, the String value of Messages.GLOBAL_MESSAGE will be one of the returned property names.

Specified by:
properties in interface Messages

size

public int size()
Description copied from interface: Messages
Return the number of messages recorded for all properties (including global messages). NOTE - it is more efficient to call empty() if all you care about is whether or not there are any messages at all.

Specified by:
size in interface Messages

size

public int size(String property)
Description copied from interface: Messages
Return the number of messages associated with the specified property.

Specified by:
size in interface Messages
Parameters:
property - Property name (or Messages.GLOBAL_MESSAGE_KEY


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.