|
Smack | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jivesoftware.smack.packet.Packet
org.jivesoftware.smack.packet.Message
public class Message
Represents XMPP message packets. A message can be one of several types:
Message type | |||||
Field | Normal | Chat | Group Chat | Headline | XMPPError |
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 |
Nested Class Summary | |
---|---|
static class |
Message.Body
Represents a message body, its language and the content of the message. |
static class |
Message.Type
Represents the type of a message. |
Field Summary |
---|
Fields inherited from class org.jivesoftware.smack.packet.Packet |
---|
DEFAULT_LANGUAGE, 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 | |
---|---|
Message.Body |
addBody(String language,
String body)
Adds a body with a corresponding language. |
boolean |
equals(Object o)
|
Collection<Message.Body> |
getBodies()
Returns a set of all bodies in this Message, including the default message body accessible from getBody() . |
String |
getBody()
Returns the body of the message, or null if the body has not been set. |
String |
getBody(String language)
Returns the body corresponding to the language. |
Collection<String> |
getBodyLanguages()
Returns all the languages being used for the bodies, not including the default body. |
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. |
int |
hashCode()
|
boolean |
removeBody(Message.Body body)
Removes the body from the message and returns true if the body was removed. |
boolean |
removeBody(String language)
Removes the body with the given language from the message. |
void |
setBody(String body)
Sets the body of the message. |
void |
setLanguage(String language)
Sets the xml:lang of this 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, getDefaultLanguage, getError, getExtension, getExtension, getExtensions, getExtensionsXML, getFrom, getPacketID, getProperty, getPropertyNames, getTo, getXmlns, nextID, parseXMLLang, removeExtension, setDefaultXmlns, setError, setFrom, setPacketID, setProperty, setTo |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Message()
public Message(String to)
to
- the recipient of the message.public Message(String to, Message.Type type)
to
- the user to send the message to.type
- the message type.Method Detail |
---|
public Message.Type getType()
Message.Type.normal
.
public void setType(Message.Type type)
type
- the type of the message.
IllegalArgumentException
- if null is passed in as the typepublic String getSubject()
public void setSubject(String subject)
subject
- the subject of the message.public String getBody()
public String getBody(String language)
getBody()
. Null will be returned if the language does not have
a corresponding body.
language
- the language of the body to return.
public Collection<Message.Body> getBodies()
getBody()
.
public void setBody(String body)
body
- the body of the message.public Message.Body addBody(String language, String body)
language
- the language of the body being added.body
- the body being added to the message.
Message.Body
NullPointerException
- if the body is null, a null pointer exception is thrownpublic boolean removeBody(String language)
language
- the language of the body which is to be removed
public boolean removeBody(Message.Body body)
body
- the body being removed from the message.
public Collection<String> getBodyLanguages()
public String getThread()
public void setThread(String thread)
thread
- the thread id of the message.public void setLanguage(String language)
language
- the xml:lang of this Message.public String toXML()
Packet
toXML
in class Packet
public boolean equals(Object o)
equals
in class Packet
public int hashCode()
hashCode
in class Packet
|
Smack | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |