Revision: 1790 http://spring-rich-c.svn.sourceforge.net/spring-rich-c/?rev=1790&view=rev Author: kevinstembridge Date: 2007-07-29 11:41:05 -0700 (Sun, 29 Jul 2007)
Log Message: ----------- Added javadoc, no functional changes Modified Paths: -------------- trunk/spring-richclient/support/src/main/java/org/springframework/richclient/core/DefaultMessage.java Modified: trunk/spring-richclient/support/src/main/java/org/springframework/richclient/core/DefaultMessage.java =================================================================== --- trunk/spring-richclient/support/src/main/java/org/springframework/richclient/core/DefaultMessage.java 2007-07-29 18:03:21 UTC (rev 1789) +++ trunk/spring-richclient/support/src/main/java/org/springframework/richclient/core/DefaultMessage.java 2007-07-29 18:41:05 UTC (rev 1790) @@ -29,19 +29,47 @@ import org.springframework.richclient.util.LabelUtils; import org.springframework.util.ObjectUtils; +/** + * The default implementation of the [EMAIL PROTECTED] Message} interface. This class is + * capable of rendering itself on [EMAIL PROTECTED] JTextComponent}s and [EMAIL PROTECTED] JLabel}s. + * In the case of labels, it is also able to lookup an icon to be displayed on + * the label. + * + * @see #getIcon() + * + */ public class DefaultMessage implements Message, Serializable { - private final long timestamp; + + private static final long serialVersionUID = -6524078363891514995L; + + private final long timestamp; private final String message; private final Severity severity; + /** + * A convenience instance representing an empty message. i.e. The message text + * is empty and there is no associated severity. + */ public static DefaultMessage EMPTY_MESSAGE = new DefaultMessage("", null); + /** + * Creates a new [EMAIL PROTECTED] DefaultMessage} with the given text and a default + * severity of [EMAIL PROTECTED] Severity#INFO}. + * + * @param text The message text. + */ public DefaultMessage(String text) { this(text, Severity.INFO); } + /** + * Creates a new [EMAIL PROTECTED] DefaultMessage} with the given text and severity. + * + * @param message The message text. + * @param severity The severity of the message. May be null. + */ public DefaultMessage(String message, Severity severity) { if (message == null) { message = ""; @@ -63,6 +91,13 @@ return severity; } + /** + * Renders this message on the given GUI component. This implementation only + * supports components of type [EMAIL PROTECTED] JTextComponent} or [EMAIL PROTECTED] JLabel}. + * + * @throws IllegalArgumentException if [EMAIL PROTECTED] component} is not a [EMAIL PROTECTED] JTextComponent} + * or a [EMAIL PROTECTED] JLabel}. + */ public void renderMessage(JComponent component) { if (component instanceof JTextComponent) { ((JTextComponent)component).setText(getMessage()); @@ -77,6 +112,16 @@ } } + /** + * Returns the icon associated with this instance's severity. The icon is + * expected to be retrieved using a key [EMAIL PROTECTED] severity.<SEVERITY_LABEL>}. + * + * @return 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 Severity#getLabel() + * @see IconSource#getIcon(String) + */ public Icon getIcon() { if (severity == null) { return null; @@ -94,8 +139,8 @@ if (!(o instanceof DefaultMessage)) { return false; } - DefaultMessage m = (DefaultMessage)o; - return message.equals(m.message) && ObjectUtils.nullSafeEquals(severity, m.severity); + DefaultMessage other = (DefaultMessage)o; + return this.message.equals(other.message) && ObjectUtils.nullSafeEquals(this.severity, other.severity); } public int hashCode() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ spring-rich-c-cvs mailing list spring-rich-c-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs