org.jabber.jabberbeans
Class ContentPacket
java.lang.Object
|
+--org.jabber.jabberbeans.XMLData
|
+--org.jabber.jabberbeans.ContentPacket
- Direct Known Subclasses:
- InfoQuery, Message, Presence, Route, XDB, XDB12
- public abstract class ContentPacket
- extends XMLData
- implements Packet, Extension, java.io.Serializable
A ContentPacket
is derived from a Packet
,a single
unit of information to be sent (or received) from the server. The three
base types of packets currently 'known' are IQ, Presence and Message.
The ContentPacket
is an abstract class that combines elements
of these three types together, such as destination and origination (to and
from) addresses, the xml identifier, packet type, etc. This creates a
significant improvement on the amount of duplicated code between these three
elements.
- Version:
- $Revision: 1.1.1.1 $
- Author:
- David Waite
<dwaite@jabber.com>, $Author: lucky $
- See Also:
- Serialized Form
Field Summary |
protected java.lang.String |
errorCode
Error code on event of an error (type=error). |
protected java.lang.String |
errorText
Extended description of the error. |
protected java.util.Vector |
extensions
A list of extensions attached to this object. |
protected JID |
fromAddress
The address that this packet is coming from - your address (or blank)
for outgoing packets, the originator's address for incoming packets. |
protected java.lang.String |
identifier
An identifier that is echoed in data replies/errors of this packet. |
protected JID |
toAddress
The address that this packet is being sent to - the destination for
outgoing packets, you (the recipient) for incoming packets. |
protected java.lang.String |
type
A packet subtype. |
Constructor Summary |
protected |
ContentPacket(PacketBuilder packet)
This constructor builds the packet portion of packet-derived objects. |
Method Summary |
protected void |
appendAnyError(java.lang.StringBuffer sb)
appendAnyError will add the error information,if any exists
for this packet. |
protected void |
appendBaseAttribs(java.lang.StringBuffer sb)
appendBaseAttribs is a helper funnction which adds the
base attributes to a StringBuffer which is being used to be return
a XML representation of the packet.. |
java.util.Enumeration |
Extensions()
Extensions returns an enumeration of extensions, if
any |
java.lang.String |
getErrorCode()
getErrorCode gets the HTTP-style error code for this packet
. |
java.lang.String |
getErrorText()
getErrorText gets the error text, a fuller textual
description of the problem encountered. |
JID |
getFromAddress()
getFromAddress returns the address of the sender of this
message. |
java.lang.String |
getIdentifier()
getIdentifier returns a string which uniquely identifies
this packet in the XML stream. |
JID |
getToAddress()
getToAddress returns the address of the recipiant of this
message. |
java.lang.String |
getType()
getType returns the subtype of this packet. |
Methods inherited from class java.lang.Object |
,
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
registerNatives,
wait,
wait,
wait |
toAddress
protected JID toAddress
- The address that this packet is being sent to - the destination for
outgoing packets, you (the recipient) for incoming packets.
fromAddress
protected JID fromAddress
- The address that this packet is coming from - your address (or blank)
for outgoing packets, the originator's address for incoming packets.
identifier
protected java.lang.String identifier
- An identifier that is echoed in data replies/errors of this packet.
Identifiers are meant to be unique per XML stream, and not duplicated.
type
protected java.lang.String type
- A packet subtype. For instance, a message can be a normal message, a
message in a one-on-one chat, a groupchat message or a headline.
errorCode
protected java.lang.String errorCode
- Error code on event of an error (type=error). This is supposed to
always hold the numerical value of the error code (which are very
close to the HTTP error codes).
errorText
protected java.lang.String errorText
- Extended description of the error.
extensions
protected java.util.Vector extensions
- A list of extensions attached to this object. Note that some derived
classes will support only one extension at a time (e.g. InfoQuery)
ContentPacket
protected ContentPacket(PacketBuilder packet)
- This constructor builds the packet portion of packet-derived objects.
Note that due to different requirements of packet-derived objects,
these values are not checked.
Only derived types are real Jabber data elements, so you cannot directly
create a ContentPacket object. Create a Message, Presence, or InfoQuery
instead.
- Parameters:
packet
- a PacketBuilder
which holds the value of the
packet parameters
getToAddress
public JID getToAddress()
getToAddress
returns the address of the recipiant of this
message. Can be blank (null)
- Returns:
JID
who this packet was addressed to.
getFromAddress
public JID getFromAddress()
getFromAddress
returns the address of the sender of this
message. Can be blank (null)
- Returns:
JID
this packet originated from.
getIdentifier
public java.lang.String getIdentifier()
getIdentifier
returns a string which uniquely identifies
this packet in the XML stream. Any reply (such as an IQ type=result or
an error message) will carry this same identifier. Identifiers are not
meant to be duplicated in a stream.
- Returns:
- a
String
value
getType
public java.lang.String getType()
getType
returns the subtype of this packet. Its context
and correctness is determined by the final packet type (message, iq,etc)
according to the jabber protocol specifications on protocol.jabber.org.
- Returns:
String
holding the type
getErrorCode
public java.lang.String getErrorCode()
getErrorCode
gets the HTTP-style error code for this packet
. All packets can potentially return errors. Error information without
the packet having subtype type="error" is considered invalid.
- Returns:
- a
String
holding the error code
getErrorText
public java.lang.String getErrorText()
getErrorText
gets the error text, a fuller textual
description of the problem encountered. Error information without the
packet having subtype type="error" is considered invalid.
- Returns:
- a
String
value
Extensions
public java.util.Enumeration Extensions()
Extensions
returns an enumeration of extensions, if
any
- Returns:
- an
Enumeration
value, or null if no extensions
appendBaseAttribs
protected void appendBaseAttribs(java.lang.StringBuffer sb)
appendBaseAttribs
is a helper funnction which adds the
base attributes to a StringBuffer which is being used to be return
a XML representation of the packet..
- Parameters:
sb
- a StringBuffer
value
appendAnyError
protected void appendAnyError(java.lang.StringBuffer sb)
appendAnyError
will add the error information,if any exists
for this packet.
- Parameters:
sb
- StringBuffer which we are injecting data into