org.jabber.jabberbeans
Class ContentPacket

java.lang.Object
  |
  +--org.jabber.jabberbeans.XMLData
        |
        +--org.jabber.jabberbeans.ContentPacket
All Implemented Interfaces:
Extension, Packet, java.io.Serializable
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.

See Also:
Serialized Form

Field Summary
protected  PacketError error
          Extended description of the error (when type=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
 PacketError getError()
          getError gets the whole error tag, a tag according to JEP-0086.
 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 org.jabber.jabberbeans.XMLData
appendAttrib, appendAttrib, appendChild, appendChild, appendItem, escapeString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jabber.jabberbeans.Packet
appendItem, toString
 
Methods inherited from interface org.jabber.jabberbeans.Extension.Extension
appendItem, toString
 

Field Detail

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.


error

protected PacketError error
Extended description of the error (when type=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)

Constructor Detail

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
Method Detail

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

getError

public PacketError getError()
getError gets the whole error tag, a tag according to JEP-0086.

Returns:
a PacketError 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