org.xmpp.packet
Class PacketExtension

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

@NotThreadSafe
public class PacketExtension
extends java.lang.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 java.util.Map<org.dom4j.QName,java.lang.Class<? extends PacketExtension>> 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(java.lang.String name, java.lang.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 java.lang.Class<? extends PacketExtension> getExtensionClass(java.lang.String name, java.lang.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 final org.dom4j.DocumentFactory docFactory

registeredExtensions

protected static final java.util.Map<org.dom4j.QName,java.lang.Class<? extends PacketExtension>> 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(java.lang.String name,
                       java.lang.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 java.lang.Class<? extends PacketExtension> getExtensionClass(java.lang.String name,
                                                                           java.lang.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.


Copyright © 2009-2010 Ignite Realtime. All Rights Reserved.