public class Message extends Packet
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 |
Modifier and Type | Class and Description |
---|---|
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.
|
DEFAULT_LANGUAGE, ID_NOT_AVAILABLE
Constructor and Description |
---|
Message()
Creates a new, "normal" message.
|
Message(java.lang.String to)
Creates a new "normal" message to the specified recipient.
|
Message(java.lang.String to,
Message.Type type)
Creates a new message of the specified type to a recipient.
|
Modifier and Type | Method and Description |
---|---|
Message.Body |
addBody(java.lang.String language,
java.lang.String body)
Adds a body with a corresponding language.
|
Message.Subject |
addSubject(java.lang.String language,
java.lang.String subject)
Adds a subject with a corresponding language.
|
boolean |
equals(java.lang.Object o) |
java.util.Collection<Message.Body> |
getBodies()
Returns a set of all bodies in this Message, including the default message body accessible
from
getBody() . |
java.lang.String |
getBody()
Returns the default body of the message, or null if the body has not been set.
|
java.lang.String |
getBody(java.lang.String language)
Returns the body corresponding to the language.
|
java.util.Collection<java.lang.String> |
getBodyLanguages()
Returns all the languages being used for the bodies, not including the default body.
|
java.lang.String |
getLanguage()
Returns the xml:lang of this Message.
|
java.lang.String |
getSubject()
Returns the default subject of the message, or null if the subject has not been set.
|
java.lang.String |
getSubject(java.lang.String language)
Returns the subject corresponding to the language.
|
java.util.Collection<java.lang.String> |
getSubjectLanguages()
Returns all the languages being used for the subjects, not including the default subject.
|
java.util.Collection<Message.Subject> |
getSubjects()
Returns a set of all subjects in this Message, including the default message subject accessible
from
getSubject() . |
java.lang.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(java.lang.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(java.lang.String language)
Removes the subject with the given language from the message.
|
void |
setBody(java.lang.String body)
Sets the body of the message.
|
void |
setLanguage(java.lang.String language)
Sets the xml:lang of this Message.
|
void |
setSubject(java.lang.String subject)
Sets the subject of the message.
|
void |
setThread(java.lang.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.
|
XmlStringBuilder |
toXML()
Returns the packet as XML.
|
addCommonAttributes, addExtension, addExtensions, getDefaultLanguage, getError, getExtension, getExtension, getExtensions, getExtensionsXML, getFrom, getPacketID, getTo, getXmlns, nextID, removeExtension, setDefaultXmlns, setError, setFrom, setPacketID, setTo, toString
public Message()
public Message(java.lang.String to)
to
- the recipient of the message.public Message(java.lang.String to, Message.Type type)
to
- the user to send the message to.type
- the message type.public Message.Type getType()
Message.Type.normal
.public void setType(Message.Type type)
type
- the type of the message.java.lang.IllegalArgumentException
- if null is passed in as the typepublic java.lang.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 java.lang.String getSubject(java.lang.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 java.util.Collection<Message.Subject> getSubjects()
getSubject()
.public void setSubject(java.lang.String subject)
subject
- the subject of the message.public Message.Subject addSubject(java.lang.String language, java.lang.String subject)
language
- the language of the subject being added.subject
- the subject being added to the message.Message.Subject
java.lang.NullPointerException
- if the subject is null, a null pointer exception is thrownpublic boolean removeSubject(java.lang.String language)
language
- the language of the subject which is to be removedpublic boolean removeSubject(Message.Subject subject)
subject
- the subject being removed from the message.public java.util.Collection<java.lang.String> getSubjectLanguages()
public java.lang.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 java.lang.String getBody(java.lang.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 java.util.Collection<Message.Body> getBodies()
getBody()
.public void setBody(java.lang.String body)
body
- the body of the message.public Message.Body addBody(java.lang.String language, java.lang.String body)
language
- the language of the body being added.body
- the body being added to the message.Message.Body
java.lang.NullPointerException
- if the body is null, a null pointer exception is thrownpublic boolean removeBody(java.lang.String language)
language
- the language of the body which is to be removedpublic boolean removeBody(Message.Body body)
body
- the body being removed from the message.public java.util.Collection<java.lang.String> getBodyLanguages()
public java.lang.String getThread()
public void setThread(java.lang.String thread)
thread
- the thread id of the message.public java.lang.String getLanguage()
public void setLanguage(java.lang.String language)
language
- the xml:lang of this Message.public XmlStringBuilder toXML()
Packet