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

📄 nodeimpl.java

📁 用Java写的面相对象的数据库管理系统
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/** * 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.ozoneDB.*;import org.ozoneDB.xml.dom.iterator.*;import org.w3c.dom.*;public abstract class NodeImpl extends OzoneObject implements NodeProxy, Externalizable {        final static long serialVersionUID = 1;        //    public Object invoke (String methodName, String sig, Object[] args)    //            throws Exception {    //        if (methodName.equals ("getNodeName")    //            return    //        }            public boolean supports( java.lang.String feature, java.lang.String version ) {        throw new DOMException( DOMException.NOT_SUPPORTED_ERR,                "ozone's persistent DOM doesn't support DOM level 2 yet." );    }             public void normalize() {        throw new DOMException( DOMException.NOT_SUPPORTED_ERR,                "ozone's persistent DOM doesn't support DOM level 2 yet." );    }             public java.lang.String getNamespaceURI() {        throw new DOMException( DOMException.NOT_SUPPORTED_ERR,                "ozone's persistent DOM doesn't support DOM level 2 yet." );    }             public java.lang.String getPrefix() {        throw new DOMException( DOMException.NOT_SUPPORTED_ERR,                "ozone's persistent DOM doesn't support DOM level 2 yet." );    }             public void setPrefix( java.lang.String prefix ) throws DOMException {        throw new DOMException( DOMException.NOT_SUPPORTED_ERR,                "ozone's persistent DOM doesn't support DOM level 2 yet." );    }             public java.lang.String getLocalName() {        throw new DOMException( DOMException.NOT_SUPPORTED_ERR,                "ozone's persistent DOM doesn't support DOM level 2 yet." );    }             /**     * Abstract method must be implemented by each node class.     *     * @see org.w3c.dom.Node#getNodeType     */    public abstract short getNodeType();            /**     * Returns the name of the node, set from the constructor. Some derived classes     * do not have the notion of a name, and will return the same name each time.     * They should do so by setting the default name (e.g. <TT>"#comment"</TT>)     * in the constructor. This value is never null.     *     * @see org.w3c.dom.Node#getNodeName     */    public final String getNodeName() {        return _nodeName;    }             /**     */    public final void setNodeName( String nodeName ) {        _nodeName = nodeName;    }             /**     * Returns the value of the node. Depending on the node type, this value     * is either the node value (e.g. the text in {@link org.w3c.dom.Text}),     * or always null is node has no notion of a value (e.g. {@link     * org.w3c.dom.Element}). For complete list of which node types will return     * what, see {@link #setNodeValue}.     *     * @return Value of node, null if node has no value     */    public final String getNodeValue() {        return _nodeValue;    }             /**     * Changes the value of the node. Not all node types support the notion of     * a value. If the value is not supported by a particular node type, it will     * throw an exception when calling this method. The following table specifies     * which node types support values:     * <PRE>     * Element                  Not supported     * Attr                     Value supported     * Text                     Value supported     * CDATASection             Value supported     * EntityReference          Not supported     * Entity                   Not supported     * ProcessingInstruction    Value supported     * Comment                  Value supported     * Document                 Not supported     * DocumentType             Not supported     * DocumentFragment         Not supported     * Notation                 Not supported     * </PRE>     * For most node types, if the value is set to null, {@link #getNodeValue}     * will return an empty string instead.     *     * @param value New value of node     * @throws org.w3c.dom.DOMExceptionImpl <TT>NO_MODIFICATION_ALLOWED_ERR</TT>     *  Node is read-only and cannot be modified     * @throws org.w3c.dom.DOMExceptionImpl <TT>NO_DATA_ALLOWED_ERR</TT>     *  This node does not support a value     */    public void setNodeValue( String value ) {        if (isReadOnly()) {            throw new DOMExceptionImpl( DOMException.NO_MODIFICATION_ALLOWED_ERR );        }         _nodeValue = value == null ? "" : value;    }             /**     * Returns the parent node of this node. Node may not necessarily have a     * parent node. If node has been created but not added to any other node,     * it will be parentless. The {@link org.w3c.dom.Document} node is always     * parentless.     *     * @return Parent node of this node     */    public Node getParentNode() {        return _parent;    }             /**     */    public void setParentNode( Node newParent ) {        _parent = (NodeProxy)newParent;    }             /**     * Called to notify all the iterators created from this node that a     * child of this node has been removed. Iterators that point at this     * child might choose to select another child to point to. This method     * is called before the child is removed.     * <P>     * The removed node is a direct child of this node. Affected iterators     * are those that point at the document tree directly below this node,     * or the tree below one of its parents. Other iterators are not affected     * by the change. This method also performs a notification on all the     * parents of this node.     *     * @param removedChild The child node being removed     */    protected void notifyIterators( Node removedChild ) {    /*FIXME        NodeProxy   node;        int         i;        node = this;        while ( node != null ) {            if ( node._iterators != null )                for ( i = node._iterators.length ; i -- > 0 ; )                    ( (NodeIteratorListener) node._iterators[ i ] ).removeNode( removedChild );            node = (NodeProxy) node.getParentNode();            }     */    }             /**     * Returns a {@link org.w3c.dom.NodeList} object that can be used to traverse     * this node's children. The node list is live, so every change to this node     * is reflected in it.     * <P>     * If children are not supported by the derived class, an exception is thrown.     *     * @return {@link org.w3c.dom.NodeList} on this node     * @throws org.w3c.dom.DOMException HIERARCHY_REQUEST_ERR Childern not supported     *  by this node type     * @see org.w3c.dom.NodeList     * @see NodeListImpl     */    public NodeList getChildNodes() {        // Throw exception if children not supported by derived class.        if (!supportsChildern()) {            throw new DOMExceptionImpl( DOMException.HIERARCHY_REQUEST_ERR,                    "No childern supported by this node type." );        }         return (NodeList)new org.ozoneDB.xml.dom.NodeListImpl( this );    }             /**     * Returns the first child of the node. If node has no children, returns null.     *     * @return First child or null     */    public final Node getFirstChild() {        return _firstChild;    }             /**     * Returns the last child of the node. If node has no children, returns null.     *     * @return Last child or null     */    public final Node getLastChild() {        return _lastChild;    }             /**     * Returns the previous sibling of this node. If node has no previous siblings,     * returns null.     *     * @return Previous sibling or null     */    public Node getPreviousSibling() {        return _prevNode;    }             /**     */    public void setPreviousSibling( Node prevNode ) {        _prevNode = (NodeProxy)prevNode;    }             /**     * Returns the next sibling of this node. If node has no next siblings,     * returns null.     *     * @return Next sibling or null     */    public Node getNextSibling() {        return _nextNode;    }             /**     */    public void setNextSibling( Node nextNode ) {        _nextNode = (NodeProxy)nextNode;    }             /**     * Return attributes of node. Returns null unless node is of type {@link     * org.w3c.dom.Element}, in which case the returned {@link     * org.w3c.dom.NamedNodeMap} will provide access to all the element's     * attributes.     *     * @return Attributes of node or null     */    public NamedNodeMap getAttributes() {        return null;    }     public boolean hasAttributes() {        throw new DOMException( DOMException.NOT_SUPPORTED_ERR,                "ozone's persistent DOM doesn't support DOM level 2 yet." );    }                    public final Document getOwnerDocument() {        if (_ownerDocument != this) {            return _ownerDocument;        } else {            return null;        }     }             /**     * Return true if there are any childern to this node. Less intensive than     * calling {#link getChildNodes}.     *     * @return True if node has any children     */    public final boolean hasChildNodes() {        return _firstChild != null;    }             /**     * Insert <TT>newChild</TT> as the last child of this parent.     * <P>     * If <TT>newChild</TT> is null, <TT>newChild</TT> does not belong to this DOM,     * or childern are not supported by this node type, an exception is thrown.     * <P>     * <TT>newChild</TT> is removed from its original parent before adding to this     * parent. If <TT>newChild</TT> is a {@link org.w3c.dom.DocumentFragment}, all     * its children are inserted one by one into this parent.     *     * @param newChild The new child to add     * @return The newly inserted child     * @throws org.w3c.dom.DOMException <TT>NO_MODIFICATION_ALLOWED_ERR</TT>     *  Node is read-only and cannot be modified     * @throws org.w3c.dom.DOMException <TT>HIERARCHY_REQUEST_ERR</TT>     *  Children are not supported by this node type, or <TT>newChild</TT> is not     *  a compatible type for this node     * @see #castNewChild     * @see #castOldChild     */    public synchronized final Node appendChild( Node newChild ) {        // Node arguments must be casted to NodeEx in order to operate on them.        NodeProxy newChildX;                // Make sure the node is not read-only.        // Throw exception if children not supported by derived class.        if (isReadOnly()) {            throw new DOMExceptionImpl( DOMException.NO_MODIFICATION_ALLOWED_ERR );        }         if (!supportsChildern()) {            throw new DOMExceptionImpl( DOMException.HIERARCHY_REQUEST_ERR,                    "No childern supported by this node type." );        }                 // Cast newChild to NodeImpl and make sure it can be inserted to this node.        newChildX = (NodeProxy)castNewChild( newChild );                // We're going to mess with this child node, so make sure no other thread        // is touching it        synchronized (newChild) {            // If the newChild is already a child or some node, remove it first            // before becoming child of this node. Make sure that parent is not            // read-only.            if (newChildX.getParentNode() != null) {                if (((NodeProxy)newChildX.getParentNode()).isReadOnly()) {                    throw new DOMExceptionImpl( DOMException.NO_MODIFICATION_ALLOWED_ERR );                }                 newChildX.getParentNode().removeChild( newChildX );            }                         // Special case: newChild is a DocumentFragment and instead of adding            // itself, all of its childs are added one by one.            if (newChildX instanceof DocumentFragment) {                NodeProxy nextChild;                                newChildX = (NodeProxy)newChildX.getFirstChild();                while (newChildX != null) {

⌨️ 快捷键说明

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