org.jabber.jabberbeans
Class PacketBuilder

java.lang.Object
  |
  +--org.jabber.jabberbeans.PacketBuilder
All Implemented Interfaces:
java.io.Serializable
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.

See Also:
Serialized Form

Field Summary
protected  PacketError error
          XMPP error tag
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
 PacketError getError()
          get the error tag
 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 setError(PacketError error)
          set the error tag
 void setErrorCode(java.lang.String errorCode)
          Deprecated. - use setError() instead
 void setErrorText(java.lang.String errText)
          Deprecated. - use setError() instead
 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, 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)


error

protected PacketError error
XMPP error tag


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


getFromAddress

public JID getFromAddress()
get the sender address

Returns:
a value of type 'JID'.

setFromAddress

public void setFromAddress(JID from)
set the sender address


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)
Deprecated. - use setError() instead

set the error type number


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)
Deprecated. - use setError() instead

set the error textual description


getError

public PacketError getError()
get the error tag

Returns:
a value of type 'PacketError'

setError

public void setError(PacketError error)
set the error tag


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.