~vcs-imports/xena/trunk

« back to all changes in this revision

Viewing changes to ext/src/xerces-2_9_1/src/org/apache/xerces/dom/PSVIDOMImplementationImpl.java

  • Committer: matthewoliver
  • Date: 2009-12-10 03:18:07 UTC
  • Revision ID: vcs-imports@canonical.com-20091210031807-l086qguzdlljtkl9
Merged Xena Testing into Xena Stable for the Xena 5 release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
 
3
 * contributor license agreements.  See the NOTICE file distributed with
 
4
 * this work for additional information regarding copyright ownership.
 
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
 
6
 * (the "License"); you may not use this file except in compliance with
 
7
 * the License.  You may obtain a copy of the License at
 
8
 * 
 
9
 *      http://www.apache.org/licenses/LICENSE-2.0
 
10
 * 
 
11
 * Unless required by applicable law or agreed to in writing, software
 
12
 * distributed under the License is distributed on an "AS IS" BASIS,
 
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
14
 * See the License for the specific language governing permissions and
 
15
 * limitations under the License.
 
16
 */
 
17
 
 
18
package org.apache.xerces.dom;
 
19
 
 
20
import org.w3c.dom.DOMException;
 
21
import org.w3c.dom.DOMImplementation;
 
22
import org.w3c.dom.Document;
 
23
import org.w3c.dom.DocumentType;
 
24
import org.w3c.dom.Element;
 
25
 
 
26
/**
 
27
 * The DOMImplementation class is description of a particular
 
28
 * implementation of the Document Object Model. As such its data is
 
29
 * static, shared by all instances of this implementation.
 
30
 * <P>
 
31
 * The DOM API requires that it be a real object rather than static
 
32
 * methods. However, there's nothing that says it can't be a singleton,
 
33
 * so that's how I've implemented it.
 
34
 * 
 
35
 * @xerces.internal
 
36
 *
 
37
 * @version $Id: PSVIDOMImplementationImpl.java,v 1.2 2009/12/10 03:18:32 matthewoliver Exp $
 
38
 * @since  PR-DOM-Level-1-19980818.
 
39
 */
 
40
public class PSVIDOMImplementationImpl extends CoreDOMImplementationImpl {
 
41
 
 
42
    //
 
43
    // Data
 
44
    //
 
45
 
 
46
    // static
 
47
 
 
48
    /** Dom implementation singleton. */
 
49
    static PSVIDOMImplementationImpl singleton = new PSVIDOMImplementationImpl();
 
50
 
 
51
    //
 
52
    // Public methods
 
53
    //
 
54
 
 
55
    /** NON-DOM: Obtain and return the single shared object */
 
56
    public static DOMImplementation getDOMImplementation() {
 
57
        return singleton;
 
58
    }  
 
59
 
 
60
    //
 
61
    // DOMImplementation methods
 
62
    //
 
63
 
 
64
    /** 
 
65
     * Test if the DOM implementation supports a specific "feature" --
 
66
     * currently meaning language and level thereof.
 
67
     * 
 
68
     * @param feature      The package name of the feature to test.
 
69
     * In Level 1, supported values are "HTML" and "XML" (case-insensitive).
 
70
     * At this writing, org.apache.xerces.dom supports only XML.
 
71
     *
 
72
     * @param version      The version number of the feature being tested.
 
73
     * This is interpreted as "Version of the DOM API supported for the
 
74
     * specified Feature", and in Level 1 should be "1.0"
 
75
     *
 
76
     * @return    true iff this implementation is compatable with the specified
 
77
     * feature and version.
 
78
     */
 
79
    public boolean hasFeature(String feature, String version) {
 
80
        return super.hasFeature(feature, version) ||
 
81
               feature.equalsIgnoreCase("psvi");
 
82
    } // hasFeature(String,String):boolean
 
83
    
 
84
    /**
 
85
     * Introduced in DOM Level 2. <p>
 
86
     * 
 
87
     * Creates an XML Document object of the specified type with its document
 
88
     * element.
 
89
     *
 
90
     * @param namespaceURI     The namespace URI of the document
 
91
     *                         element to create, or null. 
 
92
     * @param qualifiedName    The qualified name of the document
 
93
     *                         element to create. 
 
94
     * @param doctype          The type of document to be created or null.<p>
 
95
     *
 
96
     *                         When doctype is not null, its
 
97
     *                         Node.ownerDocument attribute is set to
 
98
     *                         the document being created.
 
99
     * @return Document        A new Document object.
 
100
     * @throws DOMException    WRONG_DOCUMENT_ERR: Raised if doctype has
 
101
     *                         already been used with a different document.
 
102
     * @since WD-DOM-Level-2-19990923
 
103
     */
 
104
    public Document           createDocument(String namespaceURI, 
 
105
                                             String qualifiedName, 
 
106
                                             DocumentType doctype)
 
107
                                             throws DOMException
 
108
    {
 
109
        if (doctype != null && doctype.getOwnerDocument() != null) {
 
110
            throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, 
 
111
                                   DOMMessageFormatter.formatMessage(
 
112
                                   DOMMessageFormatter.XML_DOMAIN, 
 
113
                                                       "WRONG_DOCUMENT_ERR", null));
 
114
        }
 
115
        DocumentImpl doc = new PSVIDocumentImpl(doctype);
 
116
        // If namespaceURI and qualifiedName are null return a Document with no document element.
 
117
        if (qualifiedName != null || namespaceURI != null) {
 
118
            Element e = doc.createElementNS(namespaceURI, qualifiedName);
 
119
            doc.appendChild(e);
 
120
        }
 
121
        return doc;
 
122
    }
 
123
    
 
124
 
 
125
} // class DOMImplementationImpl