|
Smack | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| 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.Subject
Represents a message subject, its language and the content of the subject. |
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. |
Message.Subject |
addSubject(String language,
String subject)
Adds a subject 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 default 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 |
getLanguage()
Returns the xml:lang of this Message. |
String |
getSubject()
Returns the default subject of the message, or null if the subject has not been set. |
String |
getSubject(String language)
Returns the subject corresponding to the language. |
Collection<String> |
getSubjectLanguages()
Returns all the languages being used for the subjects, not including the default subject. |
Collection<Message.Subject> |
getSubjects()
Returns a set of all subjects in this Message, including the default message subject accessible from getSubject(). |
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. |
boolean |
removeSubject(Message.Subject subject)
Removes the subject from the message and returns true if the subject was removed. |
boolean |
removeSubject(String language)
Removes the subject 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, 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()
The default subject of a message is the subject that corresponds to the message's language.
(see getLanguage()) or if no language is set to the applications default
language (see Packet.getDefaultLanguage()).
public String getSubject(String language)
getSubject(). Null will be returned if the language does not have
a corresponding subject.
language - the language of the subject to return.
public Collection<Message.Subject> getSubjects()
getSubject().
public void setSubject(String subject)
subject - the subject of the message.
public Message.Subject addSubject(String language,
String subject)
language - the language of the subject being added.subject - the subject being added to the message.
Message.Subject
NullPointerException - if the subject is null, a null pointer exception is thrownpublic boolean removeSubject(String language)
language - the language of the subject which is to be removed
public boolean removeSubject(Message.Subject subject)
subject - the subject being removed from the message.
public Collection<String> getSubjectLanguages()
public String getBody()
The default body of a message is the body that corresponds to the message's language.
(see getLanguage()) or if no language is set to the applications default
language (see Packet.getDefaultLanguage()).
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 String getLanguage()
public void setLanguage(String language)
language - the xml:lang of this Message.public String toXML()
Packet
toXML in class Packetpublic boolean equals(Object o)
equals in class Packetpublic int hashCode()
hashCode in class Packet
|
Smack | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||