⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 documentimpl.java

📁 Java的面向对象数据库系统的源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/** * org/ozone-db/xml/dom/DocumentImpl.java * * The contents of this file are subject to the OpenXML Public * License Version 1.0; you may not use this file except in compliance * with the License. You may obtain a copy of the License at * http://www.openxml.org/license.html * * THIS SOFTWARE IS DISTRIBUTED ON AN "AS IS" BASIS WITHOUT WARRANTY * OF ANY KIND, EITHER EXPRESSED OR IMPLIED. THE INITIAL DEVELOPER * AND ALL CONTRIBUTORS SHALL NOT BE LIABLE FOR ANY DAMAGES AS A * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS * DERIVATIVES. SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING * RIGHTS AND LIMITATIONS UNDER THE LICENSE. * * The Initial Developer of this code under the License is Assaf Arkin. * Portions created by Assaf Arkin are Copyright (C) 1998, 1999. * All Rights Reserved. *//** * Changes for Persistent DOM running with ozone are * Copyright 1999 by SMB GmbH. All rights reserved. */package org.ozoneDB.xml.dom;import java.util.*;import java.io.*;import org.w3c.dom.*;import org.ozoneDB.*;import org.ozoneDB.xml.dom.*;import org.ozoneDB.xml.util.XMLContainerHelper;/** * Implements an XML document, and also derived to implement an HTML document. * Provides access to the top level element in the document ({@link * #getDocumentElement}), to the DTD if one exists ({@link #getDoctype}, * and to all node operations. * <P> * Several methods create new nodes of all basic types (comment, text, element, * etc.). These methods create new nodes but do not place them in the document * tree. The nodes may be placed in the document tree using {@link * org.w3c.dom.Node#appendChild} or {@link org.w3c.dom.Node#insertBefore}, or * they may be placed in some other document tree. * <P> * Notes: * <OL> * <LI>Node type is {@link org.w3c.dom.Node#DOCUMENT_NODE} * <LI>Node supports childern * <LI>Node name is always "#document" * <LI>Node does not have a value * <LI>Node may not be added to other nodes * </OL> * This class contains some extensions beyond the DOM API definition. For a list * of all extensions, see {@link org.ozoneDB.xml.XMLDocument}. * * * @version $Revision$ $Date$ * @author <a href="mailto:arkin@trendline.co.il">Assaf Arkin</a> * @see org.w3c.dom.Document * @see NodeImpl * @see org.w3c.dom.DOMImplementation */public class DocumentImpl extends NodeImpl implements DocumentProxy {    final static long serialVersionUID = 1;    private XMLContainerHelper container;    /**     * The document type definition of this document (per DOM API). Only available     * if document was created with a DTD and not available for HTML documents.     */    private DocumentTypeProxy _docType;    /**     * Holds a reference to the locking thread. When unlocked, this reference is     * null. This object is used both to designate a lock, identify the locking     * thread, and perform a {@link Object#wait}.     *     * @see #lock     * @see #unlock     */    private Thread _lockThread;    /**     * Implement counting on locks, allowing {@link #lock} to be called a     * multiple number of times, and {@link #unlock} to still retain the lock     * on the outer calls.     *     * @see #lock     * @see #unlock     */    private int _lockCount;    /**     * Holds names and classes of application element types. When an element     * with a particular tag name is created, the matching {@link java.lang.Class}     * is used to create the element object. This reference is null unless an     * element has been defined.     */    private Hashtable _elementTypes;    public void writeExternal( ObjectOutput out ) throws IOException {        super.writeExternal( out );        out.writeObject ( container );    }    public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException {        super.readExternal( in );        container = (XMLContainerHelper)in.readObject();    }    /**     * Set the container of this document. This is needed to find the     * container that is responsible for a given Node.     */    public void setContainer( XMLContainerHelper _container ) {        this.container = _container;    }    /**     * Get the container of this document. This is needed to find the     * container that is responsible for a given Node.     */    public XMLContainerHelper getContainer() {        return this.container;    }    public Node importNode( Node importedNode, boolean deep ) throws DOMException {        throw new DOMExceptionImpl( DOMException.NOT_SUPPORTED_ERR,                "Document.importNode() : ozone's persistent DOM doesn't support DOM level 2 yet." );    }    public Element createElementNS( java.lang.String namespaceURI, java.lang.String qualifiedName )            throws DOMException {        throw new DOMExceptionImpl( DOMException.NOT_SUPPORTED_ERR,                "Document.createElementNS() : ozone's persistent DOM doesn't support DOM level 2 yet." );    }    public Attr createAttributeNS( java.lang.String namespaceURI, java.lang.String qualifiedName ) throws DOMException {        throw new DOMExceptionImpl( DOMException.NOT_SUPPORTED_ERR,                "Document.createAttributeNS() : ozone's persistent DOM doesn't support DOM level 2 yet." );    }    public NodeList getElementsByTagNameNS( java.lang.String namespaceURI, java.lang.String localName ) {        throw new DOMExceptionImpl( DOMException.NOT_SUPPORTED_ERR,                "Document.getElementsByTagNameNS() : ozone's persistent DOM doesn't support DOM level 2 yet." );    }    public Element getElementById( java.lang.String elementId ) {        throw new DOMExceptionImpl( DOMException.NOT_SUPPORTED_ERR,                "Document.getElementById() : ozone's persistent DOM doesn't support DOM level 2 yet." );    }    public Document createDocument( java.lang.String namespaceURI, java.lang.String qualifiedName,            DocumentType doctype ) throws DOMException {        throw new DOMExceptionImpl( DOMException.NOT_SUPPORTED_ERR,                "Document.createDocument() : ozone's persistent DOM doesn't support DOM level 2 yet." );    }    public DocumentType createDocumentType( java.lang.String qualifiedName, java.lang.String publicId,            java.lang.String systemId ) throws DOMException {        throw new DOMExceptionImpl( DOMException.NOT_SUPPORTED_ERR,                "Document.createDocumentType() : ozone's persistent DOM doesn't support DOM level 2 yet." );    }    public short getNodeType() {        return DOCUMENT_NODE;    }    public final void setNodeValue( String value ) {        throw new DOMExceptionImpl( DOMException.NO_DATA_ALLOWED_ERR, "This node type does not support values." );    }    public final DocumentType getDoctype() {        return _docType;    }    public final void setDoctype( DocumentType docType ) {        _docType = (DocumentTypeProxy)docType;    }    public final DOMImplementation getImplementation() {        return this;    }    public Element getDocumentElement() {        Node child;        // Returns the top-level element in this document. Might not exist, or        // might be the first of many.        child = getFirstChild();        while (child != null) {            if (child instanceof Element) {                return (Element)child;            }            child = child.getNextSibling();        }        return null;    }    public void setElementTypes( Hashtable elementTypes ) {        _elementTypes = elementTypes;    }    public Element createElement( String tagName ) throws DOMException {        ElementProxy elem = null;        try {            elem = (ElementProxy)database().createObject( ElementImpl.class.getName() );            elem.init( this, tagName, null, true );        } catch (Exception except) {            throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );        }        return elem;    }    public final DocumentFragment createDocumentFragment() {        DocumentFragmentProxy fragment = null;        try {            fragment = (DocumentFragmentProxy)database().createObject( DocumentFragmentImpl.class.getName() );            fragment.init( this, null );        } catch (Exception except) {            throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );        }        return fragment;    }    public final Text createTextNode( String data ) {        TextProxy text = null;        try {            text = (TextProxy)database().createObject( TextImpl.class.getName() );            text.init( this, data );        } catch (Exception except) {            throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );        }        return text;    }    public final Comment createComment( String data ) {        CommentProxy comment = null;        try {            comment = (CommentProxy)database().createObject( CommentImpl.class.getName() );            comment.init( this, data );        } catch (Exception except) {            throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );        }        return comment;    }    public final CDATASection createCDATASection( String data ) throws DOMException {        CDATASectionProxy section = null;        try {            section = (CDATASectionProxy)database().createObject( CDATASectionImpl.class.getName() );            section.init( this, data );        } catch (Exception except) {            throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );        }        return section;    }    public final ProcessingInstruction createProcessingInstruction( String target, String data ) throws DOMException {        ProcessingInstructionProxy pi = null;        try {            pi = (ProcessingInstructionProxy)database().createObject( ProcessingInstructionImpl.class.getName() );            pi.init( this, target, data );        } catch (Exception except) {            throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );        }        return pi;    }    public final Attr createAttribute( String name ) throws DOMException {        AttrProxy attr = null;        try {            attr = (AttrProxy)database().createObject( AttrImpl.class.getName() );            attr.init( this, name, "" );        } catch (Exception except) {            except.printStackTrace();            throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );        }        return attr;    }    /**     * Creates an attribute with the default value specified in the DTD.     * This method is not defined in the DOM but is used by the parser.     *     * @param name The name of the attribute     * @param defValue The default value of the attribute     */    public final Attr createAttribute( String name, String defValue ) throws DOMException {        AttrProxy attr = null;        try {            attr = (AttrProxy)database().createObject( AttrImpl.class.getName() );            attr.init( this, name, defValue == null ? "" : defValue );        } catch (Exception except) {            throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );        }        return attr;    }    public final EntityReference createEntityReference( String name ) throws DOMException {        EntityReferenceProxy entity = null;        try {            entity = (EntityReferenceProxy)database().createObject( EntityReferenceImpl.class.getName() );        // entity.init (this, name);        } catch (Exception except) {            throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -