KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > xml > xhtml > dom > xerces > XHTMLDOMImplementationImpl


1 package org.enhydra.xml.xhtml.dom.xerces;
2     
3 import org.enhydra.apache.xerces.dom.DOMImplementationImpl;
4 import org.w3c.dom.DOMException JavaDoc;
5 import org.w3c.dom.DOMImplementation JavaDoc;
6 import org.w3c.dom.Document JavaDoc;
7 import org.w3c.dom.DocumentType JavaDoc;
8 import org.w3c.dom.Element JavaDoc;
9 import org.w3c.dom.html.HTMLDOMImplementation;
10 import org.w3c.dom.html.HTMLDocument;
11
12 /**
13  * Provides number of methods for performing operations that are independent
14  * of any particular instance of the document object model. This class is
15  * unconstructable, the only way to obtain an instance of a DOM implementation
16  * is by calling the static method {@link #getDOMImplementation}.
17  *
18  * @version $Revision: 1.2 $ $Date: 2005/01/26 08:28:45 $
19  * @author <a HREF="mailto:arkin@exoffice.com">Assaf Arkin</a>
20  * @see org.w3c.dom.DOMImplementation
21  */

22 public class XHTMLDOMImplementationImpl
23     extends DOMImplementationImpl
24     implements HTMLDOMImplementation
25 {
26     /**
27      * Holds a reference to the single instance of the DOM implementation.
28      * Only one instance is required since this class is multiple entry.
29      */

30     private static HTMLDOMImplementation _instance = new XHTMLDOMImplementationImpl();
31
32
33     /**
34      * Private constructor assures that an object of this class cannot
35      * be created. The only way to obtain an object is by calling {@link
36      * #getDOMImplementation}.
37      */

38     private XHTMLDOMImplementationImpl()
39     {
40     }
41
42
43     /**
44      * @see org.w3c.dom.DOMImplementation
45      */

46     public Document JavaDoc createDocument(String JavaDoc namespaceURI,
47                    String JavaDoc qualifiedName,
48                    DocumentType JavaDoc doctype) throws DOMException JavaDoc {
49     if (qualifiedName == null) {
50         throw new NullPointerException JavaDoc("qualifiedName is null");
51         }
52         Document JavaDoc doc = new XHTMLDocumentImpl(doctype);
53         Element JavaDoc e = doc.createElementNS(namespaceURI, qualifiedName);
54         doc.appendChild(e);
55         return doc;
56     }
57
58
59     /**
60      * Create a new HTML document of the specified <TT>TITLE</TT> text.
61      *
62      * @param title The document title text
63      * @return New HTML document
64      */

65     public final HTMLDocument createHTMLDocument( String JavaDoc title )
66         throws DOMException JavaDoc
67     {
68     HTMLDocument doc;
69
70     if ( title == null )
71         throw new NullPointerException JavaDoc( "HTM014 Argument 'title' is null." );
72     doc = new XHTMLDocumentImpl();
73     doc.setTitle( title );
74     return doc;
75     }
76
77
78     /**
79      * Returns an instance of a {@link HTMLDOMImplementation} that can be
80      * used to perform operations that are not specific to a particular
81      * document instance, e.g. to create a new document.
82      *
83      * @return Reference to a valid DOM implementation
84      */

85     public static HTMLDOMImplementation getHTMLDOMImplementation()
86     {
87     return _instance;
88     }
89
90     /**
91      * Returns an instance of a {@link HTMLDOMImplementation} that can be
92      * used to perform operations that are not specific to a particular
93      * document instance, e.g. to create a new document.
94      *
95      * @return Reference to a valid DOM implementation
96      */

97     public static DOMImplementation JavaDoc getDOMImplementation()
98     {
99     return _instance;
100     }
101 }
102
Popular Tags