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

📄 namespacenode.java

📁 Java的面向对象数据库系统的源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     */
    public Document getOwnerDocument() {
        // FIXME: this could cause confusion
        return (parent == null ? null : parent.getOwnerDocument());
    }


    /**
     * Insert a new child node (always fails).
     *
     * @exception DOMException always thrown.
     * @see Node#insertBefore
     */
    public Node insertBefore(Node newChild, Node refChild)
            throws DOMException {
        no_mods();
        return null;
    }


    /**
     * Replace a child node (always fails).
     *
     * @exception DOMException always thrown.
     * @see Node#replaceChild
     */
    public Node replaceChild(Node newChild, Node oldChild)
            throws DOMException {
        no_mods();
        return null;
    }


    /**
     * Remove a child node (always fails).
     *
     * @exception DOMException always thrown.
     * @see Node#removeChild
     */
    public Node removeChild(Node oldChild)
            throws DOMException {
        no_mods();
        return null;
    }


    /**
     * Append a new child node (always fails).
     *
     * @exception DOMException always thrown.
     * @see Node#appendChild
     */
    public Node appendChild(Node newChild)
            throws DOMException {
        no_mods();
        return null;
    }


    /**
     * Test for child nodes.
     *
     * @return Always false.
     */
    public boolean hasChildNodes() {
        return false;
    }


    /**
     * Create a copy of this node.
     *
     * @param deep Make a deep copy (no effect, since Namespace nodes
     *        don't have children).
     * @return A new copy of this Namespace node.
     */
    public Node cloneNode(boolean deep) {
        return new NamespaceNode(parent, name, value);
    }


    /**
     * Normalize the text descendants of this node.
     *
     * <p>This method has no effect, since Namespace nodes have no
     * descendants.</p>
     */
    public void normalize() {
        // no op
    }


    /**
     * Test if a DOM2 feature is supported.
     *
     * @param feature The feature name.
     * @param version The feature version.
     * @return Always false.
     */
    public boolean isSupported(String feature, String version) {
        return false;
    }


    /**
     * Get the Namespace URI for this node.
     *
     * <p>Namespace declarations are not themselves
     * Namespace-qualified.</p>
     *
     * @return Always null.
     */
    public String getNamespaceURI() {
        return null;
    }


    /**
     * Get the Namespace prefix for this node.
     *
     * <p>Namespace declarations are not themselves
     * Namespace-qualified.</p>
     *
     * @return Always null.
     */
    public String getPrefix() {
        return null;
    }


    /**
     * Change the Namespace prefix for this node (always fails).
     *
     * @param prefix The new prefix.
     * @exception DOMException always thrown.
     */
    public void setPrefix(String prefix)
            throws DOMException {
        no_mods();
    }


    /**
     * Get the local name for this node.
     *
     * @return Always null.
     */
    public String getLocalName() {
        return name;
    }


    /**
     * Test if this node has attributes.
     *
     * @return Always false.
     */
    public boolean hasAttributes() {
        return false;
    }


    /**
     * Throw a NO_MODIFICATION_ALLOWED_ERR DOMException.
     *
     * @exception DOMException always thrown.
     */
    private void no_mods()
            throws DOMException {
        throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
                "Namespace node may not be modified");
    }



    ////////////////////////////////////////////////////////////////////
    // Override default methods from java.lang.Object.
    ////////////////////////////////////////////////////////////////////


    /**
     * Generate a hash code for a Namespace node.
     *
     * <p>The hash code is the sum of the hash codes of the parent node,
     * name, and value.</p>
     *
     * @return A hash code for this node.
     */
    public int hashCode() {
        return hashCode(parent) + hashCode(name) + hashCode(value);
    }


    /**
     * Test for equivalence with another object.
     *
     * <p>Two Namespace nodes are considered equivalent if their parents,
     * names, and values are equal.</p>
     *
     * @param o The object to test for equality.
     * @return true if the object is equivalent to this node, false
     *         otherwise.
     */
    public boolean equals(Object o) {
        if (o == this)
            return true;
        else if (o == null)
            return false;
        else if (o instanceof NamespaceNode) {
            NamespaceNode ns = (NamespaceNode) o;
            return (equals(parent, ns.getParentNode()) &&
                    equals(name, ns.getNodeName()) &&
                    equals(value, ns.getNodeValue()));
        } else {
            return false;
        }
    }


    /**
     * Helper method for generating a hash code.
     *
     * @param o The object for generating a hash code (possibly null).
     * @return The object's hash code, or 0 if the object is null.
     * @see java.lang.Object#hashCode
     */
    private int hashCode(Object o) {
        return (o == null ? 0 : o.hashCode());
    }


    /**
     * Helper method for comparing two objects.
     *
     * @param a The first object to compare (possibly null).
     * @param b The second object to compare (possibly null).
     * @return true if the objects are equivalent or are both null.
     * @see java.lang.Object#equals
     */
    private boolean equals(Object a, Object b) {
        return ((a == null && b == null) ||
                (a != null && a.equals(b)));
    }


    ////////////////////////////////////////////////////////////////////
    // Internal state.
    ////////////////////////////////////////////////////////////////////

    private Node parent;
    private String name;
    private String value;



    ////////////////////////////////////////////////////////////////////
    // Inner class: empty node list.
    ////////////////////////////////////////////////////////////////////


    /**
     * A node list with no members.
     *
     * <p>This class is necessary for the {@link Node#getChildNodes}
     * method, which must return an empty node list rather than
     * null when there are no children.</p>
     */
    class EmptyNodeList implements NodeList {

        /**
         * @see NodeList#getLength
         */
        public int getLength() {
            return 0;
        }


        /**
         * @see NodeList#item
         */
        public Node item(int index) {
            return null;
        }
    }
}

// end of Namespace.java

⌨️ 快捷键说明

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