rpg.core
Class ChatMessage

java.lang.Object
  extended by rpg.core.ChatMessage
All Implemented Interfaces:
java.io.Serializable

public class ChatMessage
extends java.lang.Object
implements java.io.Serializable

ChatMessage represents a single message sent through the chat system. It supports styled text via ChatMarkup. Internally, a message is represented as a List of objects, either ChatMarkup instances or String instances. ChatMarkup objects indicate markup that is applied to all subsequent strings, until the next ChatMarkup object is encountered.

See Also:
Serialized Form

Constructor Summary
ChatMessage()
          Creates a new ChatMessage with a single string as the message.
ChatMessage(java.lang.String s)
          Creates a new ChatMessage with a single string as the message.
 
Method Summary
 void addToMessage(ChatMarkup token)
          Appends an element to this message.
 void addToMessage(ChatMessage m)
          Appends the contents of another message to this one, including all markup.
 void addToMessage(java.lang.String token)
          Appends an element to this message.
 java.util.List getMessage()
          Returns a List holding the message components.
 java.lang.String getMessageAsString()
          Returns a simple String equivalent of this message.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ChatMessage

public ChatMessage()
Creates a new ChatMessage with a single string as the message.


ChatMessage

public ChatMessage(java.lang.String s)
Creates a new ChatMessage with a single string as the message.

Parameters:
s - the string to use as the message
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getMessage

public java.util.List getMessage()
Returns a List holding the message components.


getMessageAsString

public java.lang.String getMessageAsString()
Returns a simple String equivalent of this message. Note that this discards all ChatMarkup objects in the return value; use this method for logging to a file or something similar, where styled text is not supported.


addToMessage

public void addToMessage(java.lang.String token)
Appends an element to this message.

Parameters:
token - a string to use as message text

addToMessage

public void addToMessage(ChatMarkup token)
Appends an element to this message.

Parameters:
token - a ChatMarkup instance to use

addToMessage

public void addToMessage(ChatMessage m)
Appends the contents of another message to this one, including all markup.

Parameters:
m - the message to append to this one