|
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 | |
---|---|
static String |
ID_NOT_AVAILABLE
Constant used as packetID to indicate that a packet has no id. |
Constructor Summary | |
---|---|
Packet()
|
Method Summary | |
---|---|
void |
addExtension(PacketExtension extension)
Adds a packet extension to the packet. |
void |
deleteProperty(String name)
Deletes a property. |
XMPPError |
getError()
Returns the error associated with this packet, or null if there are no errors. |
PacketExtension |
getExtension(String elementName,
String namespace)
Returns the first packet extension that matches the specified element name and namespace, or null if it doesn't exist. |
Iterator |
getExtensions()
Returns an Iterator for the packet extensions attached to the packet. |
protected String |
getExtensionsXML()
Returns the extension sub-packets (including properties data) as an XML String, or the Empty String if there are no packet extensions. |
String |
getFrom()
Returns who the packet is being sent "from" or null if the value is not set. |
String |
getPacketID()
Returns the unique ID of the packet. |
Object |
getProperty(String name)
Returns the packet property with the specified name or null if the property doesn't exist. |
Iterator |
getPropertyNames()
Returns an Iterator for all the property names that are set. |
String |
getTo()
Returns who the packet is being sent "to", or null if the value is not set. |
void |
removeExtension(PacketExtension extension)
Removes a packet extension from the packet. |
void |
setError(XMPPError error)
Sets the error for this packet. |
void |
setFrom(String from)
Sets who the packet is being sent "from". |
void |
setPacketID(String packetID)
Sets the unique ID of the packet. |
void |
setProperty(String name,
boolean value)
Sets a packet property with a bboolean value. |
void |
setProperty(String name,
double value)
Sets a packet property with a double value. |
void |
setProperty(String name,
float value)
Sets a packet property with a float value. |
void |
setProperty(String name,
int value)
Sets a packet property with an int value. |
void |
setProperty(String name,
long value)
Sets a packet property with a long value. |
void |
setProperty(String name,
Object value)
Sets a property with an Object as the value. |
void |
setTo(String to)
Sets who the packet is being sent "to". |
abstract String |
toXML()
Returns the packet as XML. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String ID_NOT_AVAILABLE
Constructor Detail |
---|
public Packet()
Method Detail |
---|
public String getPacketID()
public void setPacketID(String packetID)
packetID
- the unique ID for the packet.public String getTo()
public void setTo(String to)
to
- who the packet is being sent to.public String getFrom()
public void setFrom(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 Iterator getExtensions()
public PacketExtension getExtension(String elementName, 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.namespace
- the XML element namespace of the packet extension.
public void addExtension(PacketExtension extension)
extension
- a packet extension.public void removeExtension(PacketExtension extension)
extension
- the packet extension to remove.public Object getProperty(String name)
name
- the name of the property.
public void setProperty(String name, int value)
name
- the name of the property.value
- the value of the property.public void setProperty(String name, long value)
name
- the name of the property.value
- the value of the property.public void setProperty(String name, float value)
name
- the name of the property.value
- the value of the property.public void setProperty(String name, double value)
name
- the name of the property.value
- the value of the property.public void setProperty(String name, boolean value)
name
- the name of the property.value
- the value of the property.public void setProperty(String name, Object value)
name
- the name of the property.value
- the value of the property.public void deleteProperty(String name)
name
- the name of the property to delete.public Iterator getPropertyNames()
public abstract String toXML()
protected String getExtensionsXML()
|
Smack | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |