org.jabber.jabberbeans
Class PacketBuilder

java.lang.Object
  |
  +--org.jabber.jabberbeans.PacketBuilder
Direct Known Subclasses:
InfoQueryBuilder, MessageBuilder, PresenceBuilder, RouteBuilder, XDB12Builder, XDBBuilder, XMLStreamHeaderBuilder

public abstract class PacketBuilder
extends java.lang.Object
implements java.io.Serializable

A PacketBuilder is the base class for the builder of all the different Builder classes for Packet objects. Packet-derived objects require builders since they are immutable.

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 of a packet of type="error"
protected  java.lang.String errorText
          Error Textual Description of a packet of type="error"
protected  java.util.Vector extensions
          extensions associated with this packet.
protected  JID fromAddress
          JID for the originator of the packet
protected  java.lang.String identifier
          unique identifier for the packet
protected  JID toAddress
          JID for recipient of the packet
protected  java.lang.String type
          Subtype of the packet(defined based on the final packet type)
 
Constructor Summary
PacketBuilder()
           
 
Method Summary
 void addExtension(Extension e)
          Add an extension to this object
abstract  Packet build()
          build will create a packet based on the information in the subclassed builder
 void delExtension(Extension e)
          Remove an extension from this object
 java.lang.String getErrorCode()
          get the error code number
 java.lang.String getErrorText()
          get the error textual description
 java.util.Vector getExtensionVector()
          Returns a copy of the Vector of Extension objects
 JID getFromAddress()
          get the sender address
 java.lang.String getIdentifier()
          get the message identifier.
 JID getToAddress()
          get the current recipient
 java.lang.String getType()
          get the message type.
abstract  void reset()
          reset is a method implemented by children to reset their data.
protected  void resetBase()
          resetBase resets all information in this base class.
 void setErrorCode(java.lang.String errorCode)
          set the error type number
 void setErrorText(java.lang.String errText)
          set the error textual description
 void setFromAddress(JID from)
          set the sender address
 void setIdentifier(java.lang.String id)
          Set the message identifier.
 void setToAddress(JID to)
          set the current recipient
 void setType(java.lang.String type)
          set the message type
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

toAddress

protected JID toAddress
JID for recipient of the packet

fromAddress

protected JID fromAddress
JID for the originator of the packet

identifier

protected java.lang.String identifier
unique identifier for the packet

type

protected java.lang.String type
Subtype of the packet(defined based on the final packet type)

errorCode

protected java.lang.String errorCode
Error code of a packet of type="error"

errorText

protected java.lang.String errorText
Error Textual Description of a packet of type="error"

extensions

protected java.util.Vector extensions
extensions associated with this packet.
Constructor Detail

PacketBuilder

public PacketBuilder()
Method Detail

reset

public abstract void reset()
reset is a method implemented by children to reset their data.

resetBase

protected final void resetBase()
resetBase resets all information in this base class.

getToAddress

public JID getToAddress()
get the current recipient
Returns:
a value of type 'JID'

setToAddress

public void setToAddress(JID to)
set the current recipient
Parameters:
user - a value of type 'JID'

getFromAddress

public JID getFromAddress()
get the sender address
Returns:
a value of type 'JID'.

setFromAddress

public void setFromAddress(JID from)
set the sender address
Parameters:
user - a value of type 'JID'.

getIdentifier

public java.lang.String getIdentifier()
get the message identifier. Note that a message identifier is created on the message if one isn't passed in here - read the built message if you would like to retrieve this (final) identifier.
Returns:
a value of type 'String'

setIdentifier

public void setIdentifier(java.lang.String id)
Set the message identifier. Note that if you do not set this, the message will generate one on creation.
Parameters:
id - string value of the identifier.

getType

public java.lang.String getType()
get the message type. Will return null for default (being type=normal)
Returns:
a value of type 'String'
See Also:
Jabber Protocol Site

setType

public void setType(java.lang.String type)
set the message type
Parameters:
type - a value of type 'String'
See Also:
Jabber Protocol Site

getErrorCode

public java.lang.String getErrorCode()
get the error code number
Returns:
a value of type String

setErrorCode

public void setErrorCode(java.lang.String errorCode)
set the error type number
Parameters:
type - new error type

getErrorText

public java.lang.String getErrorText()
get the error textual description
Returns:
a value of type 'String'

setErrorText

public void setErrorText(java.lang.String errText)
set the error textual description
Parameters:
text - new error description

addExtension

public void addExtension(Extension e)
Add an extension to this object
Parameters:
e - an Extension value

delExtension

public void delExtension(Extension e)
Remove an extension from this object
Parameters:
e - an Extension value

getExtensionVector

public java.util.Vector getExtensionVector()
Returns a copy of the Vector of Extension objects
Returns:
an Vector value, or null if no extensions

build

public abstract Packet build()
                      throws java.lang.InstantiationException
build will create a packet based on the information in the subclassed builder
Returns:
a Packet value on success
Throws:
java.lang.InstantiationException - if insufficient information was provided to construct a packet.