public abstract class Packet extends Object
Modifier and Type | Field and Description |
---|---|
protected static String |
DEFAULT_LANGUAGE |
static String |
ID_NOT_AVAILABLE
Constant used as packetID to indicate that a packet has no id.
|
Constructor and Description |
---|
Packet() |
Modifier and Type | Method and Description |
---|---|
void |
addExtension(PacketExtension extension)
Adds a packet extension to the packet.
|
void |
deleteProperty(String name)
Deletes a property.
|
boolean |
equals(Object o) |
static 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(String namespace)
Returns the first extension of this packet that has the given namespace.
|
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.
|
Collection<PacketExtension> |
getExtensions()
Returns an unmodifiable collection of 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.
|
Collection<String> |
getPropertyNames()
Returns an unmodifiable collection of 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.
|
String |
getXmlns() |
int |
hashCode() |
static String |
nextID()
Returns the next unique id.
|
void |
removeExtension(PacketExtension extension)
Removes a packet extension from the packet.
|
static void |
setDefaultXmlns(String defaultXmlns) |
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,
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.
|
protected static final String DEFAULT_LANGUAGE
public static final String ID_NOT_AVAILABLE
public static String nextID()
public static void setDefaultXmlns(String defaultXmlns)
public String getPacketID()
public void setPacketID(String packetID)
packetID
- the unique ID for the packet.public 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(String to)
to
- who the packet is being sent to.public 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(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 Collection<PacketExtension> getExtensions()
public PacketExtension getExtension(String namespace)
namespace
- the namespace of the extension that is desired.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. (May be null)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, 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 Collection<String> getPropertyNames()
public abstract String toXML()
protected String getExtensionsXML()
public String getXmlns()
public static String getDefaultLanguage()
Copyright © 2003-2007 Jive Software.