@NotThreadSafe public class Message extends Packet
A message can have one of several Types. For each message type,
different message fields are typically used as follows:
| Message type | |||||
| Field | Normal | Chat | Group Chat | Headline | Error |
| subject | SHOULD | SHOULD NOT | SHOULD NOT | SHOULD NOT | SHOULD NOT |
| thread | OPTIONAL | SHOULD | OPTIONAL | OPTIONAL | SHOULD NOT |
| body | SHOULD | SHOULD | SHOULD | SHOULD | SHOULD NOT |
| error | MUST NOT | MUST NOT | MUST NOT | MUST NOT | MUST |
| Modifier and Type | Class and Description |
|---|---|
static class |
Message.Type
Type-safe enumeration for the type of a message.
|
docFactory, element, fromJID, toJID| Constructor and Description |
|---|
Message()
Constructs a new Message.
|
Message(org.dom4j.Element element)
Constructs a new Message using an existing Element.
|
Message(org.dom4j.Element element,
boolean skipValidation)
Constructs a new Message using an existing Element.
|
| Modifier and Type | Method and Description |
|---|---|
org.dom4j.Element |
addChildElement(String name,
String namespace)
Adds a new child element to this packet with the given name and
namespace.
|
Message |
createCopy()
Returns a deep copy of this Message.
|
String |
getBody()
Returns the body of this message or null if there is no body.
|
org.dom4j.Element |
getChildElement(String name,
String namespace)
Returns the first child element of this packet that matches the
given name and namespace.
|
String |
getSubject()
Returns the subject of this message or null if there is no subject..
|
String |
getThread()
Returns the thread value of this message, an identifier that is used for
tracking a conversation thread ("instant messaging session")
between two entities.
|
Message.Type |
getType()
Returns the type of this message
|
void |
setBody(String body)
Sets the body of this message.
|
void |
setSubject(String subject)
Sets the subject of this message.
|
void |
setThread(String thread)
Sets the thread value of this message, an identifier that is used for
tracking a conversation thread ("instant messaging session")
between two entities.
|
void |
setType(Message.Type type)
Sets the type of this message.
|
addExtension, deleteExtension, getElement, getError, getExtension, getFrom, getID, getTo, setError, setError, setFrom, setFrom, setID, setTo, setTo, toString, toXMLpublic Message()
public Message(org.dom4j.Element element)
element - the message Element.public Message(org.dom4j.Element element,
boolean skipValidation)
element - the message Element.skipValidation - true if stringprep should not be applied to the TO address.public Message.Type getType()
Message.Typepublic void setType(Message.Type type)
type - the message type.Message.Typepublic String getSubject()
public void setSubject(String subject)
subject - the subject.public String getBody()
public void setBody(String body)
body - the body.public String getThread()
public void setThread(String thread)
thread - thread value.public org.dom4j.Element getChildElement(String name, String namespace)
Child elements in extended namespaces are used to extend the features of XMPP. Examples include a "user is typing" indicator and invitations to group chat rooms. Although any valid XML can be included in a child element in an extended namespace, many common features have been standardized as XMPP Extension Protocols (XEPs).
name - the element name.namespace - the element namespace.public org.dom4j.Element addChildElement(String name, String namespace)
Child elements in extended namespaces are used to extend the features of XMPP. Examples include a "user is typing" indicator and invitations to group chat rooms. Although any valid XML can be included in a child element in an extended namespace, many common features have been standardized as XMPP Extension Protocols (XEPs).
name - the element name.namespace - the element namespace.public Message createCopy()
createCopy in class PacketCopyright © 2009–2017 Ignite Realtime. All rights reserved.