View Javadoc
1   /*
2    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3    *
4    * This code is free software; you can redistribute it and/or modify it
5    * under the terms of the GNU General Public License version 2 only, as
6    * published by the Free Software Foundation.  Oracle designates this
7    * particular file as subject to the "Classpath" exception as provided
8    * by Oracle in the LICENSE file that accompanied this code.
9    *
10   * This code is distributed in the hope that it will be useful, but WITHOUT
11   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12   * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13   * version 2 for more details (a copy is included in the LICENSE file that
14   * accompanied this code).
15   *
16   * You should have received a copy of the GNU General Public License version
17   * 2 along with this work; if not, write to the Free Software Foundation,
18   * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19   *
20   * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21   * or visit www.oracle.com if you need additional information or have any
22   * questions.
23   */
24  
25  /*
26   * This file is available under and governed by the GNU General Public
27   * License version 2 only, as published by the Free Software Foundation.
28   * However, the following notice accompanied the original version of this
29   * file and, per its terms, should not be removed:
30   *
31   * Copyright (c) 2004 World Wide Web Consortium,
32   *
33   * (Massachusetts Institute of Technology, European Research Consortium for
34   * Informatics and Mathematics, Keio University). All Rights Reserved. This
35   * work is distributed under the W3C(r) Software License [1] in the hope that
36   * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
37   * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
38   *
39   * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
40   */
41  
42  package org.w3c.dom;
43  
44  /**
45   * The <code>DOMImplementation</code> interface provides a number of methods
46   * for performing operations that are independent of any particular instance
47   * of the document object model.
48   * <p>See also the <a href='http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407'>Document Object Model (DOM) Level 3 Core Specification</a>.
49   */
50  public interface DOMImplementation {
51      /**
52       * Test if the DOM implementation implements a specific feature and
53       * version, as specified in <a href="http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#DOMFeatures">DOM Features</a>.
54       * @param feature  The name of the feature to test.
55       * @param version  This is the version number of the feature to test.
56       * @return <code>true</code> if the feature is implemented in the
57       *   specified version, <code>false</code> otherwise.
58       */
59      public boolean hasFeature(String feature,
60                                String version);
61  
62      /**
63       * Creates an empty <code>DocumentType</code> node. Entity declarations
64       * and notations are not made available. Entity reference expansions and
65       * default attribute additions do not occur..
66       * @param qualifiedName The qualified name of the document type to be
67       *   created.
68       * @param publicId The external subset public identifier.
69       * @param systemId The external subset system identifier.
70       * @return A new <code>DocumentType</code> node with
71       *   <code>Node.ownerDocument</code> set to <code>null</code>.
72       * @exception DOMException
73       *   INVALID_CHARACTER_ERR: Raised if the specified qualified name is not
74       *   an XML name according to [<a href='http://www.w3.org/TR/2004/REC-xml-20040204'>XML 1.0</a>].
75       *   <br>NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is
76       *   malformed.
77       *   <br>NOT_SUPPORTED_ERR: May be raised if the implementation does not
78       *   support the feature "XML" and the language exposed through the
79       *   Document does not support XML Namespaces (such as [<a href='http://www.w3.org/TR/1999/REC-html401-19991224/'>HTML 4.01</a>]).
80       * @since DOM Level 2
81       */
82      public DocumentType createDocumentType(String qualifiedName,
83                                             String publicId,
84                                             String systemId)
85                                             throws DOMException;
86  
87      /**
88       * Creates a DOM Document object of the specified type with its document
89       * element.
90       * <br>Note that based on the <code>DocumentType</code> given to create
91       * the document, the implementation may instantiate specialized
92       * <code>Document</code> objects that support additional features than
93       * the "Core", such as "HTML" [<a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>DOM Level 2 HTML</a>]
94       * . On the other hand, setting the <code>DocumentType</code> after the
95       * document was created makes this very unlikely to happen.
96       * Alternatively, specialized <code>Document</code> creation methods,
97       * such as <code>createHTMLDocument</code> [<a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>DOM Level 2 HTML</a>]
98       * , can be used to obtain specific types of <code>Document</code>
99       * objects.
100      * @param namespaceURI The namespace URI of the document element to
101      *   create or <code>null</code>.
102      * @param qualifiedName The qualified name of the document element to be
103      *   created or <code>null</code>.
104      * @param doctype The type of document to be created or <code>null</code>.
105      *   When <code>doctype</code> is not <code>null</code>, its
106      *   <code>Node.ownerDocument</code> attribute is set to the document
107      *   being created.
108      * @return A new <code>Document</code> object with its document element.
109      *   If the <code>NamespaceURI</code>, <code>qualifiedName</code>, and
110      *   <code>doctype</code> are <code>null</code>, the returned
111      *   <code>Document</code> is empty with no document element.
112      * @exception DOMException
113      *   INVALID_CHARACTER_ERR: Raised if the specified qualified name is not
114      *   an XML name according to [<a href='http://www.w3.org/TR/2004/REC-xml-20040204'>XML 1.0</a>].
115      *   <br>NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is
116      *   malformed, if the <code>qualifiedName</code> has a prefix and the
117      *   <code>namespaceURI</code> is <code>null</code>, or if the
118      *   <code>qualifiedName</code> is <code>null</code> and the
119      *   <code>namespaceURI</code> is different from <code>null</code>, or
120      *   if the <code>qualifiedName</code> has a prefix that is "xml" and
121      *   the <code>namespaceURI</code> is different from "<a href='http://www.w3.org/XML/1998/namespace'>;
122      *   http://www.w3.org/XML/1998/namespace</a>" [<a href='http://www.w3.org/TR/1999/REC-xml-names-19990114/'>XML Namespaces</a>]
123      *   , or if the DOM implementation does not support the
124      *   <code>"XML"</code> feature but a non-null namespace URI was
125      *   provided, since namespaces were defined by XML.
126      *   <br>WRONG_DOCUMENT_ERR: Raised if <code>doctype</code> has already
127      *   been used with a different document or was created from a different
128      *   implementation.
129      *   <br>NOT_SUPPORTED_ERR: May be raised if the implementation does not
130      *   support the feature "XML" and the language exposed through the
131      *   Document does not support XML Namespaces (such as [<a href='http://www.w3.org/TR/1999/REC-html401-19991224/'>HTML 4.01</a>]).
132      * @since DOM Level 2
133      */
134     public Document createDocument(String namespaceURI,
135                                    String qualifiedName,
136                                    DocumentType doctype)
137                                    throws DOMException;
138 
139     /**
140      *  This method returns a specialized object which implements the
141      * specialized APIs of the specified feature and version, as specified
142      * in <a href="http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#DOMFeatures">DOM Features</a>. The specialized object may also be obtained by using
143      * binding-specific casting methods but is not necessarily expected to,
144      * as discussed in . This method also allow the implementation to
145      * provide specialized objects which do not support the
146      * <code>DOMImplementation</code> interface.
147      * @param feature  The name of the feature requested. Note that any plus
148      *   sign "+" prepended to the name of the feature will be ignored since
149      *   it is not significant in the context of this method.
150      * @param version  This is the version number of the feature to test.
151      * @return  Returns an object which implements the specialized APIs of
152      *   the specified feature and version, if any, or <code>null</code> if
153      *   there is no object which implements interfaces associated with that
154      *   feature. If the <code>DOMObject</code> returned by this method
155      *   implements the <code>DOMImplementation</code> interface, it must
156      *   delegate to the primary core <code>DOMImplementation</code> and not
157      *   return results inconsistent with the primary core
158      *   <code>DOMImplementation</code> such as <code>hasFeature</code>,
159      *   <code>getFeature</code>, etc.
160      * @since DOM Level 3
161      */
162     public Object getFeature(String feature,
163                              String version);
164 
165 }