|
Smack | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jivesoftware.smack.packet.Packet
public abstract class Packet
Base class for XMPP packets. Every packet has a unique ID (which is automatically generated, but can be overriden). Optionally, the "to" and "from" fields can be set, as well as an arbitrary number of properties. Properties provide an easy mechanism for clients to share data. Each property has a String name, and a value that is a Java primitive (int, long, float, double, boolean) or any Serializable object (a Java object is Serializable when it implements the Serializable interface).
Field Summary | |
---|---|
protected static java.lang.String |
DEFAULT_LANGUAGE
|
static java.lang.String |
ID_NOT_AVAILABLE
Constant used as packetID to indicate that a packet has no id. |
Constructor Summary | |
---|---|
Packet()
|
|
Packet(Packet p)
|
Method Summary | |
---|---|
void |
addExtension(PacketExtension extension)
Adds a packet extension to the packet. |
void |
addExtensions(java.util.Collection<PacketExtension> extensions)
Adds a collection of packet extensions to the packet. |
void |
deleteProperty(java.lang.String name)
Deletes a property. |
boolean |
equals(java.lang.Object o)
|
static java.lang.String |
getDefaultLanguage()
Returns the default language used for all messages containing localized content. |
XMPPError |
getError()
Returns the error associated with this packet, or null if there are no errors. |
PacketExtension |
getExtension(java.lang.String namespace)
Returns the first extension of this packet that has the given namespace. |
PacketExtension |
getExtension(java.lang.String elementName,
java.lang.String namespace)
Returns the first packet extension that matches the specified element name and namespace, or null if it doesn't exist. |
java.util.Collection<PacketExtension> |
getExtensions()
Returns an unmodifiable collection of the packet extensions attached to the packet. |
protected java.lang.String |
getExtensionsXML()
Returns the extension sub-packets (including properties data) as an XML String, or the Empty String if there are no packet extensions. |
java.lang.String |
getFrom()
Returns who the packet is being sent "from" or null if the value is not set. |
java.lang.String |
getPacketID()
Returns the unique ID of the packet. |
java.lang.Object |
getProperty(java.lang.String name)
Returns the packet property with the specified name or null if the property doesn't exist. |
java.util.Collection<java.lang.String> |
getPropertyNames()
Returns an unmodifiable collection of all the property names that are set. |
java.lang.String |
getTo()
Returns who the packet is being sent "to", or null if the value is not set. |
java.lang.String |
getXmlns()
|
int |
hashCode()
|
static java.lang.String |
nextID()
Returns the next unique id. |
void |
removeExtension(PacketExtension extension)
Removes a packet extension from the packet. |
static void |
setDefaultXmlns(java.lang.String defaultXmlns)
|
void |
setError(XMPPError error)
Sets the error for this packet. |
void |
setFrom(java.lang.String from)
Sets who the packet is being sent "from". |
void |
setPacketID(java.lang.String packetID)
Sets the unique ID of the packet. |
void |
setProperty(java.lang.String name,
java.lang.Object value)
Sets a property with an Object as the value. |
void |
setTo(java.lang.String to)
Sets who the packet is being sent "to". |
abstract java.lang.String |
toXML()
Returns the packet as XML. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.String DEFAULT_LANGUAGE
public static final java.lang.String ID_NOT_AVAILABLE
Constructor Detail |
---|
public Packet()
public Packet(Packet p)
Method Detail |
---|
public static java.lang.String nextID()
public static void setDefaultXmlns(java.lang.String defaultXmlns)
public java.lang.String getPacketID()
public void setPacketID(java.lang.String packetID)
packetID
- the unique ID for the packet.public java.lang.String getTo()
The StringUtils class provides several useful methods for dealing with
XMPP addresses such as parsing the
bare address
,
user name
,
server
, and
resource
.
public void setTo(java.lang.String to)
to
- who the packet is being sent to.public java.lang.String getFrom()
The StringUtils class provides several useful methods for dealing with
XMPP addresses such as parsing the
bare address
,
user name
,
server
, and
resource
.
public void setFrom(java.lang.String from)
from
- who the packet is being sent to.public XMPPError getError()
public void setError(XMPPError error)
error
- the error to associate with this packet.public java.util.Collection<PacketExtension> getExtensions()
public PacketExtension getExtension(java.lang.String namespace)
namespace
- the namespace of the extension that is desired.
public PacketExtension getExtension(java.lang.String elementName, java.lang.String namespace)
ProviderManager
class to handle custom parsing. In that case, the type of the Object
will be determined by the provider.
elementName
- the XML element name of the packet extension. (May be null)namespace
- the XML element namespace of the packet extension.
public void addExtension(PacketExtension extension)
extension
- a packet extension.public void addExtensions(java.util.Collection<PacketExtension> extensions)
extensions
- a collection of packet extensionspublic void removeExtension(PacketExtension extension)
extension
- the packet extension to remove.public java.lang.Object getProperty(java.lang.String name)
name
- the name of the property.
public void setProperty(java.lang.String name, java.lang.Object value)
name
- the name of the property.value
- the value of the property.public void deleteProperty(java.lang.String name)
name
- the name of the property to delete.public java.util.Collection<java.lang.String> getPropertyNames()
public abstract java.lang.String toXML()
protected java.lang.String getExtensionsXML()
public java.lang.String getXmlns()
public static java.lang.String getDefaultLanguage()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
|
Smack | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |