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

📄 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.openxml.XMLDocument}. * * * @version $Revision: 1.30 $ $Date: 2000/11/08 13:48:17 $ * @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;            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 DOMException( DOMException.NOT_SUPPORTED_ERR,                "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 DOMException( DOMException.NOT_SUPPORTED_ERR,                "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 DOMException( DOMException.NOT_SUPPORTED_ERR,                "ozone's persistent DOM doesn't support DOM level 2 yet." );    }             public NodeList getElementsByTagNameNS( java.lang.String namespaceURI, java.lang.String localName ) {        throw new DOMException( DOMException.NOT_SUPPORTED_ERR,                "ozone's persistent DOM doesn't support DOM level 2 yet." );    }             public Element getElementById( java.lang.String elementId ) {        throw new DOMException( DOMException.NOT_SUPPORTED_ERR,                "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 DOMException( DOMException.NOT_SUPPORTED_ERR,                "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 DOMException( DOMException.NOT_SUPPORTED_ERR,                "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 (DocumentType)_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() );            ((NodeProxy)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( (DocumentProxy)this, null );        } catch (Exception except) {            throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );        }         return (DocumentFragment)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)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)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 (CDATASection)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 (ProcessingInstruction)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)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() );        }         return (EntityReference)entity;    }         /**     * Creates a document type with the specified name (the name follows the     * <TT>!DOCTYPE</TT> entity) and associates it with the document.     * If the document is HTML or already has a DTD associated with it, throws     * an exception. This method is not defined in the DOM but is used by the     * parser.     *     * @param name The name of the document type     * @param name The public identifier, if exists     * @param name The system identifier, if exists     * @throws org.w3c.dom.DOMException <T>NOT_SUPPORTED_ERR</TT>     *  Document is HTML or already has a DTD     */    /*    public final DocumentType createDocumentType (String name, String publicId,                                                  String systemId)                                                  throws DOMException {        if (isHtmlDoc () || _docType != null)            throw new DOMExceptionImpl (DOMException.NOT_SUPPORTED_ERR);        _docType = new DocumentTypeImpl( this, name );        return _docType;        }     */            public final NodeList getElementsByTagName( String tagName ) {        return (NodeList)new org.ozoneDB.xml.dom.ElementListImpl( this, tagName );    } 

⌨️ 快捷键说明

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