Openfire 3.3.2 Javadoc

org.xmpp.packet
Class Presence

java.lang.Object
  extended by org.xmpp.packet.Packet
      extended by org.xmpp.packet.Presence
Direct Known Subclasses:
JoinRoom, LeaveRoom

public class Presence
extends Packet

Presence packet. Presence packets are used to express an entity's current network availability and to notify other entities of that availability. Presence packets are also used to negotiate and manage subscriptions to the presence of other entities.

A presence optionally has a Presence.Type.

Author:
Matt Tucker

Nested Class Summary
static class Presence.Show
          Represents the presence "show" value.
static class Presence.Type
          Represents the type of a presence packet.
 
Field Summary
 
Fields inherited from class org.xmpp.packet.Packet
docFactory, element, fromJID, toJID
 
Constructor Summary
Presence()
          Constructs a new Presence.
Presence(org.dom4j.Element element)
          Constructs a new Presence using an existing Element.
Presence(org.dom4j.Element element, boolean skipValidation)
          Constructs a new Presence using an existing Element.
Presence(Presence.Type type)
          Constructs a new Presence with the specified type.
 
Method Summary
 org.dom4j.Element addChildElement(String name, String namespace)
          Adds a new child element to this packet with the given name and namespace.
 Presence createCopy()
          Returns a deep copy of this Presence.
 org.dom4j.Element getChildElement(String name, String namespace)
          Returns the first child element of this packet that matches the given name and namespace.
 int getPriority()
          Returns the priority.
 Presence.Show getShow()
          Returns the presence "show" value, which specifies a particular availability status.
 String getStatus()
          Returns the status of this presence packet, a natural-language description of availability status.
 Presence.Type getType()
          Returns the type of this presence.
 boolean isAvailable()
          Returns true if the presence type is "available".
 void setPriority(int priority)
          Sets the priority.
 void setShow(Presence.Show show)
          Sets the presence "show" value, which specifies a particular availability status.
 void setStatus(String status)
          Sets the status of this presence packet, a natural-language description of availability status.
 void setType(Presence.Type type)
          Sets the type of this presence.
 
Methods inherited from class org.xmpp.packet.Packet
addExtension, deleteExtension, getElement, getError, getExtension, getFrom, getID, getTo, setError, setError, setFrom, setFrom, setID, setTo, setTo, toString, toXML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Presence

public Presence()
Constructs a new Presence.


Presence

public Presence(Presence.Type type)
Constructs a new Presence with the specified type.

Parameters:
type - the presence type.

Presence

public Presence(org.dom4j.Element element)
Constructs a new Presence using an existing Element. This is useful for parsing incoming presence Elements into Presence objects.

Parameters:
element - the presence Element.

Presence

public Presence(org.dom4j.Element element,
                boolean skipValidation)
Constructs a new Presence using an existing Element. This is useful for parsing incoming Presence Elements into Presence objects. Stringprep validation on the TO address can be disabled. The FROM address will not be validated since the server is the one that sets that value.

Parameters:
element - the Presence Element.
skipValidation - true if stringprep should not be applied to the TO address.
Method Detail

isAvailable

public boolean isAvailable()
Returns true if the presence type is "available". This is a convenience method that is equivalent to:
getType() == null


getType

public Presence.Type getType()
Returns the type of this presence. If the presence is "available", the type will be null (in XMPP, no value for the type attribute is defined as available).

Returns:
the presence type or null if "available".
See Also:
Presence.Type

setType

public void setType(Presence.Type type)
Sets the type of this presence.

Parameters:
type - the presence type.
See Also:
Presence.Type

getShow

public Presence.Show getShow()
Returns the presence "show" value, which specifies a particular availability status. If the <show> element is not present, this method will return null. The show value can only be set if the presence type is "avaialble". A null show value is used to represent "available", which is the default.

Returns:
the presence show value..
See Also:
Presence.Show

setShow

public void setShow(Presence.Show show)
Sets the presence "show" value, which specifies a particular availability status. The show value can only be set if the presence type is "available". A null show value is used to represent "available", which is the default.

Parameters:
show - the presence show value.
Throws:
IllegalArgumentException - if the presence type is not available.
See Also:
Presence.Show

getStatus

public String getStatus()
Returns the status of this presence packet, a natural-language description of availability status.

Returns:
the status.

setStatus

public void setStatus(String status)
Sets the status of this presence packet, a natural-language description of availability status.

Parameters:
status - the status.

getPriority

public int getPriority()
Returns the priority. The valid priority range is -128 through 128. If no priority element exists in the packet, this method will return the default value of 0.

Returns:
the priority.

setPriority

public void setPriority(int priority)
Sets the priority. The valid priority range is -128 through 128.

Parameters:
priority - the priority.
Throws:
IllegalArgumentException - if the priority is less than -128 or greater than 128.

getChildElement

public org.dom4j.Element getChildElement(String name,
                                         String namespace)
Returns the first child element of this packet that matches the given name and namespace. If no matching element is found, null will be returned. This is a convenience method to avoid manipulating this underlying packet's Element instance directly.

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 Jabber Enhancement Proposals (JEPs).

Parameters:
name - the element name.
namespace - the element namespace.
Returns:
the first matching child element, or null if there is no matching child element.

addChildElement

public org.dom4j.Element addChildElement(String name,
                                         String namespace)
Adds a new child element to this packet with the given name and namespace. The newly created Element is returned. This is a convenience method to avoid manipulating this underlying packet's Element instance directly.

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 Jabber Enhancement Proposals (JEPs).

Parameters:
name - the element name.
namespace - the element namespace.
Returns:
the newly created child element.

createCopy

public Presence createCopy()
Returns a deep copy of this Presence.

Specified by:
createCopy in class Packet
Returns:
a deep copy of this Presence.

Openfire 3.3.2 Javadoc

Copyright © 2003-2007 Jive Software.