org.jrabbit.standard.profiler.util
Class Message

java.lang.Object
  extended by org.jrabbit.standard.profiler.util.Message
All Implemented Interfaces:
Referenced
Direct Known Subclasses:
Counter, Timer, ValueTracker

public class Message
extends java.lang.Object
implements Referenced

A Message is simply a utility object that manages a String (the message), and sends updates to an object whenever it is changed. The whole purpose of a Message is to provide a controlled and somewhat optimized way for ProfilerEntities to handle text they need to render. To do this, a ProfilerEntity that uses a Message should implement ChangeListener and register itself with its Message; it will then receive the minimal amount of updates possible when its message is changed. Then, the ProfilerEntity can update any necessary dimension and rendering information.

Author:
Chris Molini

Field Summary
protected  ChangeListener listener
          The listener to alert when the message changes.
protected  java.lang.String message
          The message this Message represents.
protected  java.lang.String reference
          The reference of this Message.
 
Constructor Summary
Message(java.lang.String reference)
          Creates a Message labeled by the supplied reference.
Message(java.lang.String reference, java.lang.String message)
          Creates a Message with the indicated reference and initial message.
 
Method Summary
protected  void alertListener()
          Alerts this Message's ChangeListener (if it has one) that the message has changed.
 ChangeListener listener()
          Accesses the object listening to this Message.
 java.lang.String message()
          Accesses the current message.
 java.lang.String reference()
          Accesses the identifier of this Message.
 void setListener(ChangeListener listener)
          Redefines this Message's listener.
protected  void setMessage(java.lang.String message)
          Changes the message this Message uses.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

reference

protected java.lang.String reference
The reference of this Message.


message

protected java.lang.String message
The message this Message represents.


listener

protected ChangeListener listener
The listener to alert when the message changes.

Constructor Detail

Message

public Message(java.lang.String reference)
Creates a Message labeled by the supplied reference. NOTE: The initial message defaults to 'reference + ": --"'. So, if you supply, say, "Time" as a reference, the resulting initial message will be "Time: --".

Parameters:
reference - The identifier of this Message.

Message

public Message(java.lang.String reference,
               java.lang.String message)
Creates a Message with the indicated reference and initial message.

Parameters:
reference - The identifier of this Message.
message - The initial message to use.
Method Detail

reference

public java.lang.String reference()
Accesses the identifier of this Message.

Specified by:
reference in interface Referenced
Returns:
The String that identifies this object.

message

public java.lang.String message()
Accesses the current message.

Returns:
The String that this Message represents.

setMessage

protected void setMessage(java.lang.String message)
Changes the message this Message uses. If the supplied message is different than the one currently used, this Message alerts its listener that a change has occurred.

Parameters:
message - The new message to use.

listener

public ChangeListener listener()
Accesses the object listening to this Message.

Returns:
The ChangeListener that will be notified whenever the message is altered.

setListener

public void setListener(ChangeListener listener)
Redefines this Message's listener.

Parameters:
listener - The object that should receive notification when the message changes.

alertListener

protected void alertListener()
Alerts this Message's ChangeListener (if it has one) that the message has changed.