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

📄 nodeimpl.java

📁 Java有关XML编程需要用到axis 的源代码 把里面bin下的包导入相应的Java工程 进行使用
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* * Copyright 2001-2004 The Apache Software Foundation. *  * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at *  *      http://www.apache.org/licenses/LICENSE-2.0 *  * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.axis.message;import org.apache.axis.components.logger.LogFactory;import org.apache.axis.encoding.SerializationContext;import org.apache.axis.i18n.Messages;import org.apache.commons.logging.Log;import org.w3c.dom.Attr;import org.w3c.dom.CDATASection;import org.w3c.dom.CharacterData;import org.w3c.dom.Comment;import org.w3c.dom.DOMException;import org.w3c.dom.Document;import org.w3c.dom.NamedNodeMap;import org.w3c.dom.Node;import org.w3c.dom.NodeList;import org.w3c.dom.Text;import org.xml.sax.Attributes;import org.xml.sax.helpers.AttributesImpl;import javax.xml.soap.SOAPElement;import javax.xml.soap.SOAPException;import java.io.Serializable;import java.util.ArrayList;import java.util.Iterator;/** * This is our implementation of the DOM node */public class NodeImpl implements org.w3c.dom.Node, javax.xml.soap.Node,        Serializable, Cloneable {    protected static Log log =            LogFactory.getLog(NodeImpl.class.getName());    protected String name;    protected String prefix;    protected String namespaceURI;    protected transient Attributes attributes = NullAttributes.singleton;    protected Document document = null;    protected NodeImpl parent = null;    protected ArrayList children = null;    // ...or as DOM    protected CharacterData textRep = null;    protected boolean   _isDirty = false;    private static final String NULL_URI_NAME = "intentionalNullURI";    /**     * empty constructor     */    public NodeImpl() {    }    /**     * constructor which adopts the name and NS of the char data, and its text     * @param text     */    public NodeImpl(CharacterData text) {        textRep = text;        namespaceURI = text.getNamespaceURI();        name = text.getLocalName();    }    /**     * A code representing the type of the underlying object, as defined above.     */    public short getNodeType() {        if (this.textRep != null) {            if (textRep instanceof Comment) {                return COMMENT_NODE;            } else if (textRep instanceof CDATASection) {                return CDATA_SECTION_NODE;            } else {                return TEXT_NODE;            }        } else if (false) {            return DOCUMENT_FRAGMENT_NODE;        } else if (false) {            return Node.ELEMENT_NODE;        } else { // most often but we cannot give prioeity now            return Node.ELEMENT_NODE;        }    }    /**     * Puts all <code>Text</code> nodes in the full depth of the sub-tree     * underneath this <code>Node</code>, including attribute nodes, into a     * "normal" form where only structure (e.g., elements, comments,     * processing instructions, CDATA sections, and entity references)     * separates <code>Text</code> nodes, i.e., there are neither adjacent     * <code>Text</code> nodes nor empty <code>Text</code> nodes. This can     * be used to ensure that the DOM view of a document is the same as if     * it were saved and re-loaded, and is useful when operations (such as     * XPointer  lookups) that depend on a particular document tree     * structure are to be used.In cases where the document contains     * <code>CDATASections</code>, the normalize operation alone may not be     * sufficient, since XPointers do not differentiate between     * <code>Text</code> nodes and <code>CDATASection</code> nodes.     */    public void normalize() {        //TODO: Fix this for SAAJ 1.2 Implementation    }    /**     * Returns whether this node (if it is an element) has any attributes.     *      * @return <code>true</code> if this node has any attributes,     *         <code>false</code> otherwise.     * @since DOM Level 2     */    public boolean hasAttributes() {        return attributes.getLength() > 0;    }    /**     * Returns whether this node has any children.     *      * @return <code>true</code> if this node has any children,     *         <code>false</code> otherwise.     */    public boolean hasChildNodes() {        return (children != null && !children.isEmpty());    }    /**     * Returns the local part of the qualified name of this node.     * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and     * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1     * method, such as <code>createElement</code> from the     * <code>Document</code> interface, this is always <code>null</code>.     *      * @since DOM Level 2     */    public String getLocalName() {        return name;    }    /**     * The namespace URI of this node, or <code>null</code> if it is     * unspecified.     * <br>This is not a computed value that is the result of a namespace     * lookup based on an examination of the namespace declarations in     * scope. It is merely the namespace URI given at creation time.     * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and     * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1     * method, such as <code>createElement</code> from the     * <code>Document</code> interface, this is always <code>null</code>.Per     * the Namespaces in XML Specification  an attribute does not inherit     * its namespace from the element it is attached to. If an attribute is     * not explicitly given a namespace, it simply has no namespace.     *      * @since DOM Level 2     */    public String getNamespaceURI() {        return (namespaceURI);    }    /**     * The name of this node, depending on its type; see the table above.     */    public String getNodeName() {        return (prefix != null && prefix.length() > 0) ?                prefix + ":" + name : name;    }    /**     * The value of this node, depending on its type; see the table above.     * When it is defined to be <code>null</code>, setting it has no effect.     *      * @throws org.w3c.dom.DOMException NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.     * @throws org.w3c.dom.DOMException DOMSTRING_SIZE_ERR: Raised when it would return more characters than     *                                  fit in a <code>DOMString</code> variable on the implementation     *                                  platform.     */    public String getNodeValue() throws DOMException {        if (textRep == null) {            return null;        } else {            return textRep.getData();        }    }    /**     * The namespace prefix of this node, or <code>null</code> if it is     * unspecified.     * <br>Note that setting this attribute, when permitted, changes the     * <code>nodeName</code> attribute, which holds the qualified name, as     * well as the <code>tagName</code> and <code>name</code> attributes of     * the <code>Element</code> and <code>Attr</code> interfaces, when     * applicable.     * <br>Note also that changing the prefix of an attribute that is known to     * have a default value, does not make a new attribute with the default     * value and the original prefix appear, since the     * <code>namespaceURI</code> and <code>localName</code> do not change.     * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and     * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1     * method, such as <code>createElement</code> from the     * <code>Document</code> interface, this is always <code>null</code>.     *      * @throws org.w3c.dom.DOMException INVALID_CHARACTER_ERR: Raised if the specified prefix contains an     *                                  illegal character, per the XML 1.0 specification .     *                                  <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.     *                                  <br>NAMESPACE_ERR: Raised if the specified <code>prefix</code> is     *                                  malformed per the Namespaces in XML specification, if the     *                                  <code>namespaceURI</code> of this node is <code>null</code>, if the     *                                  specified prefix is "xml" and the <code>namespaceURI</code> of this     *                                  node is different from "http://www.w3.org/XML/1998/namespace", if     *                                  this node is an attribute and the specified prefix is "xmlns" and     *                                  the <code>namespaceURI</code> of this node is different from "     *                                  http://www.w3.org/2000/xmlns/", or if this node is an attribute and     *                                  the <code>qualifiedName</code> of this node is "xmlns" .     * @since DOM Level 2     */    public String getPrefix() {        return (prefix);    }    /**     * The value of this node, depending on its type; see the table above.     * When it is defined to be <code>null</code>, setting it has no effect.     *      * @throws org.w3c.dom.DOMException NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.     * @throws org.w3c.dom.DOMException DOMSTRING_SIZE_ERR: Raised when it would return more characters than     *                                  fit in a <code>DOMString</code> variable on the implementation     *                                  platform.     */    public void setNodeValue(String nodeValue) throws DOMException {        throw new DOMException(DOMException.NO_DATA_ALLOWED_ERR,                "Cannot use TextNode.set in " + this);    }    /**     * The namespace prefix of this node, or <code>null</code> if it is     * unspecified.     * <br>Note that setting this attribute, when permitted, changes the     * <code>nodeName</code> attribute, which holds the qualified name, as     * well as the <code>tagName</code> and <code>name</code> attributes of     * the <code>Element</code> and <code>Attr</code> interfaces, when     * applicable.     * <br>Note also that changing the prefix of an attribute that is known to     * have a default value, does not make a new attribute with the default     * value and the original prefix appear, since the     * <code>namespaceURI</code> and <code>localName</code> do not change.     * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and     * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1     * method, such as <code>createElement</code> from the     * <code>Document</code> interface, this is always <code>null</code>.     *      * @throws org.w3c.dom.DOMException INVALID_CHARACTER_ERR: Raised if the specified prefix contains an     *                                  illegal character, per the XML 1.0 specification .     *                                  <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.     *                                  <br>NAMESPACE_ERR: Raised if the specified <code>prefix</code> is     *                                  malformed per the Namespaces in XML specification, if the     *                                  <code>namespaceURI</code> of this node is <code>null</code>, if the     *                                  specified prefix is "xml" and the <code>namespaceURI</code> of this     *                                  node is different from "http://www.w3.org/XML/1998/namespace", if     *                                  this node is an attribute and the specified prefix is "xmlns" and     *                                  the <code>namespaceURI</code> of this node is different from "     *                                  http://www.w3.org/2000/xmlns/", or if this node is an attribute and     *                                  the <code>qualifiedName</code> of this node is "xmlns" .     * @since DOM Level 2     */    public void setPrefix(String prefix) {        this.prefix = prefix;    }    /**     * Set the owner document     * 

⌨️ 快捷键说明

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