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

📄 elementimpl.java

📁 用Java写的面相对象的数据库管理系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/** * org/ozone-db/xml/dom/ElementImpl.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.*;/** * The most common node type, {@link org.w3c.dom.Element} inherits the generic * {@link Node} interface and adds support for retrieving and setting attributes * either as nodes or as strings. * <P> * Notes: * <OL> * <LI>Node type is {@link org.w3c.dom.Node#ELEMENT_NODE} * <LI>Node supports childern * <LI>Node has no value * <LI>Node has attributes * </OL> * <P> * To speed up implementation, all attributes are implemented as double-linked * list implemented using {@link NodeImpl#_parent}, {@link NodeImpl#_nextNode} and * {@link NodeImpl#_prevNode}. This support is provided to through {@link * #getNamedAttr}, {@link #appendAttr} and {@link #removeAttr} methods. * * * @version $Revision: 1.27 $ $Date: 2000/11/10 17:48:07 $ * @author <a href="mailto:arkin@trendline.co.il">Assaf Arkin</a> * @see org.w3c.dom.Element * @see org.w3c.dom.Attr * @see org.w3c.dom.NamedNodeMap * @see AttrImpl */public class ElementImpl extends NodeImpl implements ElementProxy, Externalizable {        final static long serialVersionUID = 1;            public Node getNamedItemNS( 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 Node setNamedItemNS( Node arg ) throws DOMException {        throw new DOMException( DOMException.NOT_SUPPORTED_ERR,                "ozone's persistent DOM doesn't support DOM level 2 yet." );    }             public Node removeNamedItemNS( java.lang.String namespaceURI, java.lang.String localName ) throws DOMException {        throw new DOMException( DOMException.NOT_SUPPORTED_ERR,                "ozone's persistent DOM doesn't support DOM level 2 yet." );    }             public Attr getAttributeNodeNS( 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 Attr setAttributeNodeNS( Attr newAttr ) throws DOMException {        throw new DOMException( DOMException.NOT_SUPPORTED_ERR,                "ozone's persistent DOM doesn't support DOM level 2 yet." );    }             public java.lang.String getAttributeNS( 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 void setAttributeNS( java.lang.String namespaceURI, java.lang.String qualifiedName, java.lang.String value )             throws DOMException {        throw new DOMException( DOMException.NOT_SUPPORTED_ERR,                "ozone's persistent DOM doesn't support DOM level 2 yet." );    }             public void removeAttributeNS( java.lang.String namespaceURI, java.lang.String localName ) 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 boolean hasAttributes() {        throw new DOMException( DOMException.NOT_SUPPORTED_ERR,                "ozone's persistent DOM doesn't support DOM level 2 yet." );    }            public boolean hasAttribute( String name ) {        throw new DOMException( DOMException.NOT_SUPPORTED_ERR,                "ozone's persistent DOM doesn't support DOM level 2 yet." );    }            public boolean hasAttributeNS( String namespaceURI, String localname ) {        throw new DOMException( DOMException.NOT_SUPPORTED_ERR,                "ozone's persistent DOM doesn't support DOM level 2 yet." );    }            public final short getNodeType() {        return ELEMENT_NODE;    }             public final Enumeration elements() {        return (Enumeration)null;    }             public void setFirstAttr( Attr attribute ) {        _firstAttr = (AttrProxy)attribute;    }             public void setLastAttr( Attr attribute ) {        _lastAttr = (AttrProxy)attribute;    }             public void setAttrCount( int count ) {        _attrCount = count;    }             /**     * Returns the name of the tag, same as calling {@link #getNodeName}.     * In XML documents, the return value preserves case. In HTML documents,     * the return value is always upper case regardless of the original value.     *     * @return Tag name     */    public final String getTagName() {        return getNodeName();    }             public final void setNodeValue( String value ) {        throw new DOMExceptionImpl( DOMException.NO_DATA_ALLOWED_ERR, "This node type does not support values." );    }             /**     * Returns a list of elements extracted based on their tag name (or all of     * them if the tag name is "*"). The returned list is a snapshot of the     * element's contents at the time of calling. Subsequent updates to the     * element are not reflected in the list. This might result in inaccuracies     * when working from multiple threads.     *     * @param tagName The element tag name to look for or "*" for all elements     * @return A snapshot of the named elements contained within this element     */    public synchronized final NodeList getElementsByTagName( String tagName ) {        // The full implementation can be found in ElementListImpl        return (NodeList)new org.ozoneDB.xml.dom.ElementListImpl( this, tagName );    }             public synchronized final void normalize() {        Node node;        Node next;                // Run through all child nodes of this element. If a particular child        // is an Element, normalize it. If a particular child is a Text and is        // followed by a second Text node, concatenate the data from the second        // to the first and remove the second node.        node = getFirstChild();        while (node != null) {            if (node instanceof ElementProxy) {                ((ElementProxy)node).normalize();            } else {                if (node instanceof TextProxy) {                    next = node.getNextSibling();                    while (next != null && next instanceof TextProxy) {                        ((TextProxy)node).appendData( ((TextProxy)next).getData() );                        removeChild( next );                        next = node.getNextSibling();                    }                 }             }             node = node.getNextSibling();        }     }             public final NamedNodeMap getAttributes() {        // This is a NamedNodeMap of all its attributes.        // return this;        return (NamedNodeMap)self();    }             public synchronized final String getAttribute( String name ) {        AttrProxy attr;                // Look for the named attribute and return it's value.        attr = (AttrProxy)getNamedAttr( name );        if (attr == null) {            return "";        }         return attr.getValue();    }             public synchronized final void setAttribute( String name, String value ) throws DOMException {        AttrProxy attr;                if (isReadOnly()) {            throw new DOMExceptionImpl( DOMException.NO_MODIFICATION_ALLOWED_ERR );        }         // If attribute value is null, might as well remove attribute. This will        // either save space, or return the default value instead.        if (value == null) {            removeAttribute( name );        } else {            try {                // Get the named attribute and change it's value. If the attribute                // does not exist, create a new attribute by that name and add it.                // Call setValue() to assure correct behavior.                attr = (AttrProxy)getNamedAttr( name );                if (attr == null) {                    attr = (AttrProxy)database().createObject( AttrImpl.class.getName() );                    attr.init( _ownerDocument, name, "" );                    appendAttr( attr );                }                 attr.setValue( value );            } catch (Exception except) {                throw new DOMExceptionImpl( DOMExceptionImpl.PDOM_ERR, except.getMessage() );            }         }     }             public synchronized final void removeAttribute( String name ) {        AttrProxy attr;                attr = (AttrProxy)getNamedAttr( name );        if (attr != null) {            removeAttr( attr );        }     }             public final Attr getAttributeNode( String name ) {        return getNamedAttr( name );    }             public synchronized final Attr setAttributeNode( Attr newAttr ) throws DOMException {        AttrProxy oldAttr;                if (isReadOnly()) {            throw new DOMExceptionImpl( DOMException.NO_MODIFICATION_ALLOWED_ERR );        }         if (newAttr == null || !(newAttr instanceof AttrProxy)) {            throw new DOMExceptionImpl( DOMException.WRONG_DOCUMENT_ERR );        }         // Note: getParentNode() will return null.        if (((AttrProxy)newAttr).getParentNode() != null) {            throw new DOMExceptionImpl( DOMException.INUSE_ATTRIBUTE_ERR );        }         synchronized (newAttr) {            oldAttr = (AttrProxy)getNamedAttr( newAttr.getName() );            if (oldAttr != null) {                removeAttr( oldAttr );            }             appendAttr( (AttrProxy)newAttr );        }         return oldAttr;    }             public synchronized final Attr removeAttributeNode( Attr oldAttr ) {        if (isReadOnly()) {            throw new DOMExceptionImpl( DOMException.NO_MODIFICATION_ALLOWED_ERR );        }         if (!(oldAttr instanceof Attr)) {            throw new DOMExceptionImpl( DOMException.HIERARCHY_REQUEST_ERR,                    "Node is not an attribute compatible with this element." );        }         oldAttr = removeAttr( (AttrProxy)oldAttr );        if (oldAttr == null) {            throw new DOMExceptionImpl( DOMException.NOT_FOUND_ERR );        }         return oldAttr;    }             public synchronized final Node getNamedItem( String name ) {        return getNamedAttr( name );    }             public final Node setNamedItem( Node arg ) throws DOMException {        if (!(arg instanceof AttrProxy)) {            throw new DOMExceptionImpl( DOMException.HIERARCHY_REQUEST_ERR,                    "Node is not an attribute compatible with this element." );        }         return setAttributeNode( (AttrProxy)arg );    }             public synchronized final Node removeNamedItem( String name ) throws DOMException {        AttrProxy attr;                attr = (AttrProxy)getNamedAttr( name );

⌨️ 快捷键说明

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