Smack

org.jivesoftware.smack.packet
Class Message

java.lang.Object
  extended by org.jivesoftware.smack.packet.Packet
      extended by org.jivesoftware.smack.packet.Message

public class Message
extends Packet

Represents XMPP message packets. A message can be one of several types:

For each message type, different message fields are typically used as follows:

 Message type
FieldNormalChatGroup ChatHeadlineXMPPError
subject SHOULDSHOULD NOTSHOULD NOTSHOULD NOTSHOULD NOT
thread OPTIONALSHOULDOPTIONALOPTIONALSHOULD NOT
body SHOULDSHOULDSHOULDSHOULDSHOULD NOT
error MUST NOTMUST NOTMUST NOTMUST NOTMUST

Author:
Matt Tucker

Nested Class Summary
static class Message.Type
          Represents the type of a message.
 
Field Summary
 
Fields inherited from class org.jivesoftware.smack.packet.Packet
ID_NOT_AVAILABLE
 
Constructor Summary
Message()
          Creates a new, "normal" message.
Message(String to)
          Creates a new "normal" message to the specified recipient.
Message(String to, Message.Type type)
          Creates a new message of the specified type to a recipient.
 
Method Summary
 String getBody()
          Returns the body of the message, or null if the body has not been set.
 String getSubject()
          Returns the subject of the message, or null if the subject has not been set.
 String getThread()
          Returns the thread id of the message, which is a unique identifier for a sequence of "chat" messages.
 Message.Type getType()
          Returns the type of the message.
 void setBody(String body)
          Sets the body of the message.
 void setSubject(String subject)
          Sets the subject of the message.
 void setThread(String thread)
          Sets the thread id of the message, which is a unique identifier for a sequence of "chat" messages.
 void setType(Message.Type type)
          Sets the type of the message.
 String toXML()
          Returns the packet as XML.
 
Methods inherited from class org.jivesoftware.smack.packet.Packet
addExtension, deleteProperty, getError, getExtension, getExtensions, getExtensionsXML, getFrom, getPacketID, getProperty, getPropertyNames, getTo, removeExtension, setError, setFrom, setPacketID, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Message

public Message()
Creates a new, "normal" message.


Message

public Message(String to)
Creates a new "normal" message to the specified recipient.

Parameters:
to - the recipient of the message.

Message

public Message(String to,
               Message.Type type)
Creates a new message of the specified type to a recipient.

Parameters:
to - the user to send the message to.
type - the message type.
Method Detail

getType

public Message.Type getType()
Returns the type of the message.

Returns:
the type of the message.

setType

public void setType(Message.Type type)
Sets the type of the message.

Parameters:
type - the type of the message.

getSubject

public String getSubject()
Returns the subject of the message, or null if the subject has not been set. The subject is a short description of message contents.

Returns:
the subject of the message.

setSubject

public void setSubject(String subject)
Sets the subject of the message. The subject is a short description of message contents.

Parameters:
subject - the subject of the message.

getBody

public String getBody()
Returns the body of the message, or null if the body has not been set. The body is the main message contents.

Returns:
the body of the message.

setBody

public void setBody(String body)
Sets the body of the message. The body is the main message contents.

Parameters:
body -

getThread

public String getThread()
Returns the thread id of the message, which is a unique identifier for a sequence of "chat" messages. If no thread id is set, null will be returned.

Returns:
the thread id of the message, or null if it doesn't exist.

setThread

public void setThread(String thread)
Sets the thread id of the message, which is a unique identifier for a sequence of "chat" messages.

Parameters:
thread - the thread id of the message.

toXML

public String toXML()
Description copied from class: Packet
Returns the packet as XML. Every concrete extension of Packet must implement this method. In addition to writing out packet-specific data, every sub-class should also write out the error and the extensions data if they are defined.

Specified by:
toXML in class Packet
Returns:
the XML format of the packet as a String.

Smack

Copyright © 2003 Jive Software.