Openfire 3.5.2 Javadoc

org.xmpp.packet
Class PacketExtension

java.lang.Object
  extended by org.xmpp.packet.PacketExtension
Direct Known Subclasses:
DataForm

public class PacketExtension
extends Object

A packet extension represents a child element of a Packet for a given qualified name. The PacketExtension acts as a wrapper on a child element the same way Packet does for a whole element. The wrapper provides an easy way to handle the packet extension.

Subclasses of this class can be registered using the static variable registeredExtensions. The registration process associates the new subclass with a given qualified name (ie. element name and namespace). This information will be used by Packet.getExtension(String, String) for locating the corresponding PacketExtension subclass to return for the requested qualified name. Each PacketExtension must have a public constructor that takes an Element instance as an argument.

Author:
Gaston Dombiak

Field Summary
protected static org.dom4j.DocumentFactory docFactory
           
protected  org.dom4j.Element element
           
protected static Map<org.dom4j.QName,Class> registeredExtensions
          Subclasses of PacketExtension should register the element name and namespace that the subclass is using.
 
Constructor Summary
PacketExtension(org.dom4j.Element element)
          Constructs a new PacketExtension.
PacketExtension(String name, String namespace)
          Constructs a new Packet extension using the specified name and namespace.
 
Method Summary
 PacketExtension createCopy()
          Creates a deep copy of this packet extension.
 org.dom4j.Element getElement()
          Returns the DOM4J Element that backs the packet.
static Class getExtensionClass(String name, String namespace)
          Returns the extension class to use for the specified element name and namespace.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

docFactory

protected static org.dom4j.DocumentFactory docFactory

registeredExtensions

protected static Map<org.dom4j.QName,Class> registeredExtensions
Subclasses of PacketExtension should register the element name and namespace that the subclass is using.


element

protected org.dom4j.Element element
Constructor Detail

PacketExtension

public PacketExtension(String name,
                       String namespace)
Constructs a new Packet extension using the specified name and namespace.

Parameters:
name - the child element name.
namespace - the child element namespace.

PacketExtension

public PacketExtension(org.dom4j.Element element)
Constructs a new PacketExtension.

Parameters:
element - the XML Element that contains the packet extension contents.
Method Detail

getExtensionClass

public static Class getExtensionClass(String name,
                                      String namespace)
Returns the extension class to use for the specified element name and namespace. For instance, the DataForm class should be used for the element "x" and namespace "jabber:x:data".

Parameters:
name - the child element name.
namespace - the child element namespace.
Returns:
the extension class to use for the specified element name and namespace.

getElement

public org.dom4j.Element getElement()
Returns the DOM4J Element that backs the packet. The element is the definitive representation of the packet and can be manipulated directly to change packet contents.

Returns:
the DOM4J Element that represents the packet.

createCopy

public PacketExtension createCopy()
Creates a deep copy of this packet extension.

Returns:
a deep copy of this packet extension.

Openfire 3.5.2 Javadoc

Copyright © 2003-2007 Jive Software.