org.springframework.richclient.core
Class DefaultMessage

java.lang.Object
  extended by org.springframework.richclient.core.DefaultMessage
All Implemented Interfaces:
Serializable, Message
Direct Known Subclasses:
DefaultValidationMessage

public class DefaultMessage
extends Object
implements Message, Serializable

The default implementation of the Message interface. This class is capable of rendering itself on JTextComponents and JLabels. In the case of labels, it is also able to lookup an icon to be displayed on the label.

See Also:
getIcon(), Serialized Form

Field Summary
static DefaultMessage EMPTY_MESSAGE
          A convenience instance representing an empty message.
 
Constructor Summary
DefaultMessage(String text)
          Creates a new DefaultMessage with the given text and a default severity of Severity.INFO.
DefaultMessage(String message, Severity severity)
          Creates a new DefaultMessage with the given text and severity.
 
Method Summary
 boolean equals(Object o)
           
 Icon getIcon()
          Returns the icon associated with this instance's severity.
 String getMessage()
          The textual representation of the message.
 Severity getSeverity()
          Return the Severity of this message, possibly null.
 long getTimestamp()
          Timestamp in long format of the message creation.
 int hashCode()
           
 void renderMessage(JComponent component)
          Renders this message on the given GUI component.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_MESSAGE

public static final DefaultMessage EMPTY_MESSAGE
A convenience instance representing an empty message. i.e. The message text is empty and there is no associated severity.

Constructor Detail

DefaultMessage

public DefaultMessage(String text)
Creates a new DefaultMessage with the given text and a default severity of Severity.INFO.

Parameters:
text - The message text.

DefaultMessage

public DefaultMessage(String message,
                      Severity severity)
Creates a new DefaultMessage with the given text and severity.

Parameters:
message - The message text.
severity - The severity of the message. May be null.
Method Detail

getTimestamp

public long getTimestamp()
Description copied from interface: Message
Timestamp in long format of the message creation.

Specified by:
getTimestamp in interface Message

getMessage

public String getMessage()
Description copied from interface: Message
The textual representation of the message. This is not necessarily how the message will appear on a GUI component.

Specified by:
getMessage in interface Message
Returns:
textual message, never null, but possibly an empty string.

getSeverity

public Severity getSeverity()
Description copied from interface: Message
Return the Severity of this message, possibly null.

Specified by:
getSeverity in interface Message

renderMessage

public void renderMessage(JComponent component)
Renders this message on the given GUI component. This implementation only supports components of type JTextComponent or JLabel.

Specified by:
renderMessage in interface Message
Parameters:
component - visual component to decorate.
Throws:
IllegalArgumentException - if component is not a JTextComponent or a JLabel.

getIcon

public Icon getIcon()
Returns the icon associated with this instance's severity. The icon is expected to be retrieved using a key severity.<SEVERITY_LABEL>.

Returns:
The icon associated with this instance's severity, or null if the instance has no specified severity, or the icon could not be found.
See Also:
AbstractGenericLabeledEnum.getLabel(), IconSource.getIcon(String)

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2004-2008 The Spring Framework. All Rights Reserved.