FileDocCategorySizeDatePackage
DOMImplementationImpl.javaAPI DocJava SE 5 API7614Fri Aug 26 14:55:42 BST 2005com.sun.org.apache.xerces.internal.dom

DOMImplementationImpl

public class DOMImplementationImpl extends CoreDOMImplementationImpl implements DOMImplementation
The DOMImplementation class is description of a particular implementation of the Document Object Model. As such its data is static, shared by all instances of this implementation.

The DOM API requires that it be a real object rather than static methods. However, there's nothing that says it can't be a singleton, so that's how I've implemented it.

version
$Id: DOMImplementationImpl.java,v 1.31 2004/01/29 20:59:52 elena Exp $
since
PR-DOM-Level-1-19980818.

Fields Summary
static DOMImplementationImpl
singleton
Dom implementation singleton.
Constructors Summary
Methods Summary
public org.w3c.dom.DocumentcreateDocument(java.lang.String namespaceURI, java.lang.String qualifiedName, org.w3c.dom.DocumentType doctype)
Introduced in DOM Level 2.

Creates an XML Document object of the specified type with its document element.

param
namespaceURI The namespace URI of the document element to create, or null.
param
qualifiedName The qualified name of the document element to create.
param
doctype The type of document to be created or null.

When doctype is not null, its Node.ownerDocument attribute is set to the document being created.

return
Document A new Document object.
throws
DOMException WRONG_DOCUMENT_ERR: Raised if doctype has already been used with a different document.
since
WD-DOM-Level-2-19990923

        if(namespaceURI == null && qualifiedName == null && doctype == null){
        //if namespaceURI, qualifiedName and doctype are null, returned document is empty with
        //no document element
            return new DocumentImpl();
        }
    	else if (doctype != null && doctype.getOwnerDocument() != null) {
            String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null);
            throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
        }
        DocumentImpl doc = new DocumentImpl(doctype);
        Element e = doc.createElementNS( namespaceURI, qualifiedName);
        doc.appendChild(e);
        return doc;
    
public static org.w3c.dom.DOMImplementationgetDOMImplementation()
NON-DOM: Obtain and return the single shared object



    //
    // Public methods
    //

             
        
        return singleton;
    
public booleanhasFeature(java.lang.String feature, java.lang.String version)
Test if the DOM implementation supports a specific "feature" -- currently meaning language and level thereof.

param
feature The package name of the feature to test. In Level 1, supported values are "HTML" and "XML" (case-insensitive). At this writing, com.sun.org.apache.xerces.internal.dom supports only XML.
param
version The version number of the feature being tested. This is interpreted as "Version of the DOM API supported for the specified Feature", and in Level 1 should be "1.0"
return
true iff this implementation is compatable with the specified feature and version.


        boolean result = super.hasFeature(feature, version);
        if (!result) {
            boolean anyVersion = version == null || version.length() == 0;
            if (feature.startsWith("+")) {
                feature = feature.substring(1);
            }
            return (
                (feature.equalsIgnoreCase("Events")
                    && (anyVersion || version.equals("2.0")))
                    || (feature.equalsIgnoreCase("MutationEvents")
                        && (anyVersion || version.equals("2.0")))
                    || (feature.equalsIgnoreCase("Traversal")
                        && (anyVersion || version.equals("2.0")))
                    || (feature.equalsIgnoreCase("Range")
                        && (anyVersion || version.equals("2.0")))
                    || (feature.equalsIgnoreCase("MutationEvents")
                        && (anyVersion || version.equals("2.0"))));
        }
        return result;