public final class Presence extends MessageOrPresence<PresenceBuilder> implements PresenceView
available -- (Default) indicates the user is available to
receive messages.
unavailable -- the user is unavailable to receive messages.
subscribe -- request subscription to recipient's presence.
subscribed -- grant subscription to sender's presence.
unsubscribe -- request removal of subscription to
sender's presence.
unsubscribed -- grant removal of subscription to
sender's presence.
error -- the presence stanza contains an error message.
A number of attributes are optional:
available (the default),
chat, away, xa (extended away), and
dnd (do not disturb).
Presence stanzas are used for two purposes. First, to notify the server of the user's current presence status. Second, they are used to subscribe and unsubscribe users from the roster.
| Modifier and Type | Class and Description |
|---|---|
static class |
Presence.Mode
An enum to represent the presence mode.
|
static class |
Presence.Type
An enum to represent the presence type.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ELEMENT |
DEFAULT_LANGUAGE, ITEM, language, TEXT| Constructor and Description |
|---|
Presence(org.jxmpp.jid.Jid to,
Presence.Type type)
Deprecated.
use
PresenceBuilder or XMPPConnection.getStanzaFactory() instead. |
Presence(Presence.Type type)
Deprecated.
use
PresenceBuilder or XMPPConnection.getStanzaFactory() instead. |
Presence(Presence.Type type,
java.lang.String status,
int priority,
Presence.Mode mode)
Deprecated.
use
PresenceBuilder or XMPPConnection.getStanzaFactory() instead. |
Presence(Presence other)
Copy constructor.
|
| Modifier and Type | Method and Description |
|---|---|
PresenceBuilder |
asBuilder() |
PresenceBuilder |
asBuilder(java.lang.String id) |
PresenceBuilder |
asBuilder(XMPPConnection connection) |
Presence |
clone()
Deprecated.
use
asBuilder() instead. |
Presence |
cloneWithNewId()
Deprecated.
use
asBuilder(XMPPConnection) or asBuilder(String)instead. |
java.lang.String |
getElementName()
Returns the root element name.
|
Presence.Mode |
getMode()
Returns the mode of the presence update.
|
int |
getPriority()
Returns the priority of the presence.
|
byte |
getPriorityByte()
Returns the priority of the presence.
|
java.lang.String |
getStatus()
Returns the status message of the presence update, or
null if there
is not a status. |
Presence.Type |
getType()
Returns the type of this presence stanza.
|
boolean |
isAvailable()
Returns true if the
presence type is available (online) and
false if the user is unavailable (offline), or if this is a presence packet
involved in a subscription operation. |
boolean |
isAway()
Returns true if the presence type is
available and the presence
mode is away, extended away, or
do not disturb. |
void |
setMode(Presence.Mode mode)
Deprecated.
use
PresenceBuilder or XMPPConnection.getStanzaFactory() instead. |
void |
setPriority(byte priority) |
void |
setPriority(int priority)
Deprecated.
use
PresenceBuilder or XMPPConnection.getStanzaFactory() instead. |
void |
setStatus(java.lang.String status)
Deprecated.
use
PresenceBuilder or XMPPConnection.getStanzaFactory() instead. |
void |
setType(Presence.Type type)
Deprecated.
use
PresenceBuilder or XMPPConnection.getStanzaFactory() instead. |
java.lang.String |
toString()
Returns a short String describing the Stanza.
|
XmlStringBuilder |
toXML(XmlEnvironment enclosingNamespace) |
addCommonAttributes, addExtension, addExtensions, appendErrorIfExists, getDefaultLanguage, getError, getExtension, getExtension, getExtension, getExtensionElement, getExtensions, getExtensions, getExtensions, getExtensions, getExtensionsMap, getFrom, getLanguage, getNamespace, getStanzaId, getTo, hasExtension, hasExtension, hasStanzaIdSet, logCommonAttributes, overrideExtension, removeExtension, removeExtension, setError, setError, setFrom, setLanguage, setNewStanzaId, setStanzaId, setStanzaId, setTo, throwIfNoStanzaIdequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetError, getExtension, getExtension, getExtensions, getExtensions, getExtensions, getFrom, getStanzaId, getTo, hasExtension, hasExtension, hasExtensiongetLanguagegetQNamepublic static final java.lang.String ELEMENT
@Deprecated public Presence(Presence.Type type)
PresenceBuilder or XMPPConnection.getStanzaFactory() instead.type - the type.@Deprecated
public Presence(org.jxmpp.jid.Jid to,
Presence.Type type)
PresenceBuilder or XMPPConnection.getStanzaFactory() instead.to - the recipient.type - the type.@Deprecated public Presence(Presence.Type type, java.lang.String status, int priority, Presence.Mode mode)
PresenceBuilder or XMPPConnection.getStanzaFactory() instead.type - the type.status - a text message describing the presence update.priority - the priority of this presence update.mode - the mode type for this presence update.public Presence(Presence other)
This does not perform a deep clone, as extension elements are shared between the new and old instance.
other - TODO javadoc me pleasepublic boolean isAvailable()
presence type is available (online) and
false if the user is unavailable (offline), or if this is a presence packet
involved in a subscription operation. This is a convenience method
equivalent to getType() == Presence.Type.available. Note that even
when the user is available, their presence mode may be away,
extended away or do not disturb. Use
isAway() to determine if the user is away.public boolean isAway()
available and the presence
mode is away, extended away, or
do not disturb. False will be returned when the type or mode
is any other value, including when the presence type is unavailable (offline).
This is a convenience method equivalent to
type == Type.available && (mode == Mode.away || mode == Mode.xa || mode == Mode.dnd).public Presence.Type getType()
PresenceViewgetType in interface PresenceView@Deprecated public void setType(Presence.Type type)
PresenceBuilder or XMPPConnection.getStanzaFactory() instead.type - the type of the presence packet.public java.lang.String getStatus()
PresenceViewnull if there
is not a status. The status is free-form text describing a user's presence
(i.e., "gone to lunch").getStatus in interface PresenceView@Deprecated public void setStatus(java.lang.String status)
PresenceBuilder or XMPPConnection.getStanzaFactory() instead.status - the status message.public int getPriority()
PresenceViewgetPriority in interface PresenceViewpublic byte getPriorityByte()
PresenceViewgetPriorityByte in interface PresenceView@Deprecated public void setPriority(int priority)
PresenceBuilder or XMPPConnection.getStanzaFactory() instead.priority - the priority of the presence.java.lang.IllegalArgumentException - if the priority is outside the valid range.public void setPriority(byte priority)
public Presence.Mode getMode()
PresenceViewgetMode in interface PresenceView@Deprecated public void setMode(Presence.Mode mode)
PresenceBuilder or XMPPConnection.getStanzaFactory() instead.Presence.Mode.available.mode - the mode.public java.lang.String getElementName()
NamedElementgetElementName in interface NamedElementpublic PresenceBuilder asBuilder()
asBuilder in class MessageOrPresence<PresenceBuilder>public PresenceBuilder asBuilder(java.lang.String id)
asBuilder in class MessageOrPresence<PresenceBuilder>public PresenceBuilder asBuilder(XMPPConnection connection)
asBuilder in class MessageOrPresence<PresenceBuilder>public java.lang.String toString()
Stanzapublic XmlStringBuilder toXML(XmlEnvironment enclosingNamespace)
@Deprecated public Presence clone()
asBuilder() instead.This does not perform a deep clone, as extension elements are shared between the new and old instance.
clone in class java.lang.Object@Deprecated public Presence cloneWithNewId()
asBuilder(XMPPConnection) or asBuilder(String)instead.