Source Code Cross Referenced for PacketExtension.java in  » Net » openfire » org » xmpp » packet » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » openfire » org.xmpp.packet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


01:        /**
02:         * Copyright (C) 2004-2007 Jive Software. All rights reserved.
03:         *
04:         * This software is published under the terms of the GNU Public License (GPL),
05:         * a copy of which is included in this distribution.
06:         */package org.xmpp.packet;
07:
08:        import org.dom4j.DocumentFactory;
09:        import org.dom4j.Element;
10:        import org.dom4j.QName;
11:
12:        import java.util.Map;
13:        import java.util.concurrent.ConcurrentHashMap;
14:
15:        /**
16:         * A packet extension represents a child element of a Packet for a given qualified name. The
17:         * PacketExtension acts as a wrapper on a child element the same way Packet does for a whole
18:         * element. The wrapper provides an easy way to handle the packet extension.<p>
19:         *
20:         * Subclasses of this class can be registered using the static variable
21:         * <tt>registeredExtensions</tt>. The registration process associates the new subclass
22:         * with a given qualified name (ie. element name and namespace). This information will be used by
23:         * {@link Packet#getExtension(String, String)} for locating the corresponding PacketExtension
24:         * subclass to return for the requested qualified name. Each PacketExtension must have a public
25:         * constructor that takes an Element instance as an argument. 
26:         *
27:         * @author Gaston Dombiak
28:         */
29:        public class PacketExtension {
30:
31:            protected static DocumentFactory docFactory = DocumentFactory
32:                    .getInstance();
33:            /**
34:             * Subclasses of PacketExtension should register the element name and namespace that the
35:             * subclass is using.
36:             */
37:            protected static Map<QName, Class> registeredExtensions = new ConcurrentHashMap<QName, Class>();
38:
39:            protected Element element;
40:
41:            /**
42:             * Returns the extension class to use for the specified element name and namespace. For
43:             * instance, the DataForm class should be used for the element "x" and
44:             * namespace "jabber:x:data".
45:             *
46:             * @param name the child element name.
47:             * @param namespace the child element namespace.
48:             * @return the extension class to use for the specified element name and namespace.
49:             */
50:            public static Class getExtensionClass(String name, String namespace) {
51:                return registeredExtensions.get(QName.get(name, namespace));
52:            }
53:
54:            /**
55:             * Constructs a new Packet extension using the specified name and namespace.
56:             *
57:             * @param name the child element name.
58:             * @param namespace the child element namespace.
59:             */
60:            public PacketExtension(String name, String namespace) {
61:                this .element = docFactory.createDocument().addElement(name,
62:                        namespace);
63:            }
64:
65:            /**
66:             * Constructs a new PacketExtension.
67:             *
68:             * @param element the XML Element that contains the packet extension contents.
69:             */
70:            public PacketExtension(Element element) {
71:                this .element = element;
72:            }
73:
74:            /**
75:             * Returns the DOM4J Element that backs the packet. The element is the definitive
76:             * representation of the packet and can be manipulated directly to change
77:             * packet contents.
78:             *
79:             * @return the DOM4J Element that represents the packet.
80:             */
81:            public Element getElement() {
82:                return element;
83:            }
84:
85:            /**
86:             * Creates a deep copy of this packet extension.
87:             *
88:             * @return a deep copy of this packet extension.
89:             */
90:            public PacketExtension createCopy() {
91:                Element copy = element.createCopy();
92:                docFactory.createDocument().add(copy);
93:                return new PacketExtension(element);
94:            }
95:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.