1 20 21 package org.xmpp.packet; 22 23 import org.dom4j.DocumentFactory; 24 import org.dom4j.Element; 25 import org.dom4j.QName; 26 27 import java.util.Map ; 28 import java.util.concurrent.ConcurrentHashMap ; 29 30 43 public abstract class PacketExtension { 44 protected static DocumentFactory docFactory = DocumentFactory.getInstance(); 45 49 protected static Map <QName, Class > registeredExtensions = new ConcurrentHashMap <QName, Class >(); 50 51 protected Element element; 52 53 62 public static Class getExtensionClass(String name, String namespace) { 63 return registeredExtensions.get(QName.get(name, namespace)); 64 } 65 66 72 public PacketExtension(String name, String namespace) { 73 this.element = docFactory.createDocument().addElement(name, namespace); 74 } 75 76 81 public PacketExtension(Element element) { 82 this.element = element; 83 } 84 85 92 public Element getElement() { 93 return element; 94 } 95 96 101 public abstract PacketExtension createCopy(); 102 } 103 | Popular Tags |