dtmnodeproxy.java

来自「JAVA 所有包」· Java 代码 · 共 2,314 行 · 第 1/5 页

JAVA
2,314
字号
            }        }*/        return false;    }      /**     *     * DOM Level 3     * Look up the prefix associated to the given namespace URI, starting from this node.     *     * @param namespaceURI     * @return the prefix for the namespace     */    public String lookupPrefix(String namespaceURI){        // REVISIT: When Namespaces 1.1 comes out this may not be true        // Prefix can't be bound to null namespace        if (namespaceURI == null) {            return null;        }        short type = this.getNodeType();        switch (type) {/*        case Node.ELEMENT_NODE: {                String namespace = this.getNamespaceURI(); // to flip out children                return lookupNamespacePrefix(namespaceURI, (ElementImpl)this);            }        case Node.DOCUMENT_NODE:{                return((NodeImpl)((Document)this).getDocumentElement()).lookupPrefix(namespaceURI);            }*/        case Node.ENTITY_NODE :        case Node.NOTATION_NODE:        case Node.DOCUMENT_FRAGMENT_NODE:        case Node.DOCUMENT_TYPE_NODE:            // type is unknown            return null;        case Node.ATTRIBUTE_NODE:{                if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {                    return getOwnerElement().lookupPrefix(namespaceURI);                }                return null;            }        default:{ /*                NodeImpl ancestor = (NodeImpl)getElementAncestor(this);                if (ancestor != null) {                    return ancestor.lookupPrefix(namespaceURI);                }*/                return null;            }         }    }     /**     * Returns whether this node is the same node as the given one.     * <br>This method provides a way to determine whether two     * <code>Node</code> references returned by the implementation reference     * the same object. When two <code>Node</code> references are references     * to the same object, even if through a proxy, the references may be     * used completely interchangably, such that all attributes have the     * same values and calling the same DOM method on either reference     * always has exactly the same effect.     * @param other The node to test against.     * @return Returns <code>true</code> if the nodes are the same,     *   <code>false</code> otherwise.     * @since DOM Level 3     */    public boolean isSameNode(Node other) {        // we do not use any wrapper so the answer is obvious        return this == other;    }      /**     * This attribute returns the text content of this node and its     * descendants. When it is defined to be null, setting it has no effect.     * When set, any possible children this node may have are removed and     * replaced by a single <code>Text</code> node containing the string     * this attribute is set to. On getting, no serialization is performed,     * the returned string does not contain any markup. No whitespace     * normalization is performed, the returned string does not contain the     * element content whitespaces . Similarly, on setting, no parsing is     * performed either, the input string is taken as pure textual content.     * <br>The string returned is made of the text content of this node     * depending on its type, as defined below:     * <table border='1'>     * <tr>     * <th>Node type</th>     * <th>Content</th>     * </tr>     * <tr>     * <td valign='top' rowspan='1' colspan='1'>     * ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE,     * DOCUMENT_FRAGMENT_NODE</td>     * <td valign='top' rowspan='1' colspan='1'>concatenation of the <code>textContent</code>     * attribute value of every child node, excluding COMMENT_NODE and     * PROCESSING_INSTRUCTION_NODE nodes</td>     * </tr>     * <tr>     * <td valign='top' rowspan='1' colspan='1'>ATTRIBUTE_NODE, TEXT_NODE,     * CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE</td>     * <td valign='top' rowspan='1' colspan='1'>     * <code>nodeValue</code></td>     * </tr>     * <tr>     * <td valign='top' rowspan='1' colspan='1'>DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE</td>     * <td valign='top' rowspan='1' colspan='1'>     * null</td>     * </tr>     * </table>     * @exception DOMException     *   NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.     * @exception DOMException     *   DOMSTRING_SIZE_ERR: Raised when it would return more characters than     *   fit in a <code>DOMString</code> variable on the implementation     *   platform.       * @since DOM Level 3     */    public void setTextContent(String textContent)        throws DOMException {        setNodeValue(textContent);    }    /**     * This attribute returns the text content of this node and its     * descendants. When it is defined to be null, setting it has no effect.     * When set, any possible children this node may have are removed and     * replaced by a single <code>Text</code> node containing the string     * this attribute is set to. On getting, no serialization is performed,     * the returned string does not contain any markup. No whitespace     * normalization is performed, the returned string does not contain the     * element content whitespaces . Similarly, on setting, no parsing is     * performed either, the input string is taken as pure textual content.     * <br>The string returned is made of the text content of this node     * depending on its type, as defined below:     * <table border='1'>     * <tr>     * <th>Node type</th>     * <th>Content</th>     * </tr>     * <tr>     * <td valign='top' rowspan='1' colspan='1'>     * ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE,     * DOCUMENT_FRAGMENT_NODE</td>     * <td valign='top' rowspan='1' colspan='1'>concatenation of the <code>textContent</code>     * attribute value of every child node, excluding COMMENT_NODE and     * PROCESSING_INSTRUCTION_NODE nodes</td>     * </tr>     * <tr>     * <td valign='top' rowspan='1' colspan='1'>ATTRIBUTE_NODE, TEXT_NODE,     * CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE</td>     * <td valign='top' rowspan='1' colspan='1'>     * <code>nodeValue</code></td>     * </tr>     * <tr>     * <td valign='top' rowspan='1' colspan='1'>DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE</td>     * <td valign='top' rowspan='1' colspan='1'>     * null</td>     * </tr>     * </table>     * @exception DOMException     *   NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.     * @exception DOMException     *   DOMSTRING_SIZE_ERR: Raised when it would return more characters than     *   fit in a <code>DOMString</code> variable on the implementation     *   platform.     * @since DOM Level 3     */    public String getTextContent() throws DOMException {        return getNodeValue();  // overriden in some subclasses    }     /**     * Compares a node with this node with regard to their position in the     * document.     * @param other The node to compare against this node.     * @return Returns how the given node is positioned relatively to this     *   node.     * @since DOM Level 3     */    public short compareDocumentPosition(Node other) throws DOMException {        return 0;    }     /**     * The absolute base URI of this node or <code>null</code> if undefined.     * This value is computed according to . However, when the     * <code>Document</code> supports the feature "HTML" , the base URI is     * computed using first the value of the href attribute of the HTML BASE     * element if any, and the value of the <code>documentURI</code>     * attribute from the <code>Document</code> interface otherwise.     * <br> When the node is an <code>Element</code>, a <code>Document</code>     * or a a <code>ProcessingInstruction</code>, this attribute represents     * the properties [base URI] defined in . When the node is a     * <code>Notation</code>, an <code>Entity</code>, or an     * <code>EntityReference</code>, this attribute represents the     * properties [declaration base URI] in the . How will this be affected     * by resolution of relative namespace URIs issue?It's not.Should this     * only be on Document, Element, ProcessingInstruction, Entity, and     * Notation nodes, according to the infoset? If not, what is it equal to     * on other nodes? Null? An empty string? I think it should be the     * parent's.No.Should this be read-only and computed or and actual     * read-write attribute?Read-only and computed (F2F 19 Jun 2000 and     * teleconference 30 May 2001).If the base HTML element is not yet     * attached to a document, does the insert change the Document.baseURI?     * Yes. (F2F 26 Sep 2001)     * @since DOM Level 3     */    public String getBaseURI() {        return null;    }        /**     * DOM Level 3     * Renaming node     */    public Node renameNode(Node n,                           String namespaceURI,                           String name)                           throws DOMException{        return n;    }        /**     *  DOM Level 3     *  Normalize document.     */    public void normalizeDocument(){       }    /**     *  The configuration used when <code>Document.normalizeDocument</code> is     * invoked.     * @since DOM Level 3     */    public DOMConfiguration getDomConfig(){       return null;    }        /** DOM Level 3 feature: documentURI */    protected String fDocumentURI;    /**     * DOM Level 3     */    public void setDocumentURI(String documentURI){                fDocumentURI= documentURI;    }        /**     * DOM Level 3     * The location of the document or <code>null</code> if undefined.     * <br>Beware that when the <code>Document</code> supports the feature     * "HTML" , the href attribute of the HTML BASE element takes precedence     * over this attribute.     * @since DOM Level 3     */    public String getDocumentURI(){        return fDocumentURI;    }        /**DOM Level 3 feature: Document actualEncoding */    protected String actualEncoding;     /**     * DOM Level 3     * An attribute specifying the actual encoding of this document. This is     * <code>null</code> otherwise.     * <br> This attribute represents the property [character encoding scheme]     * defined in .     * @since DOM Level 3     */    public String getActualEncoding() {        return actualEncoding;    }    /**     * DOM Level 3     * An attribute specifying the actual encoding of this document. This is     * <code>null</code> otherwise.     * <br> This attribute represents the property [character encoding scheme]     * defined in .     * @since DOM Level 3     */    public void setActualEncoding(String value) {        actualEncoding = value;    }     /**    * DOM Level 3    */    public Text replaceWholeText(String content)                                 throws DOMException{/*        if (needsSyncData()) {            synchronizeData();        }        // make sure we can make the replacement        if (!canModify(nextSibling)) {            throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,                DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null));        }        Node parent = this.getParentNode();        if (content == null || content.length() == 0) {            // remove current node            if (parent !=null) { // check if node in the tree                parent.removeChild(this);                return null;            }        }        Text currentNode = null;        if (isReadOnly()){            Text newNode = this.ownerDocument().createTextNode(content);            if (parent !=null) { // check if node in the tree                parent.insertBefore(newNode, this);                parent.removeChild(this);                currentNode = newNode;            } else {                return newNode;            }        }  else {            this.setData(content);            currentNode = this;        }        Node sibling =  currentNode.getNextSibling();        while ( sibling !=null) {            parent.removeChild(sibling);            sibling = currentNode.getNextSibling();        }        return currentNode;*/        return null; //Pending    }     /**     * DOM Level 3     * Returns all text of <code>Text</code> nodes logically-adjacent text     * nodes to this node, concatenated in document order.     * @since DOM Level 3     */    public String getWholeText(){/*        if (needsSyncData()) {            synchronizeData();        }        if (nextSibling == null) {            return data;        }        StringBuffer buffer = new StringBuffer();        if (data != null && data.length() != 0) {            buffer.append(data);        }        getWholeText(nextSibling, buffer);        return buffer.toString();*/        return null; // PENDING    }      /**    * DOM Level 3     * Returns whether this text node contains whitespace in element content,     * often abusively called "ignorable whitespace".     */    public boolean isElementContentWhitespace(){        return false;    }     /**     * NON-DOM: set the type of this attribute to be ID type.     *     * @param id     */    public void setIdAttribute(boolean id){        //PENDING    }     /**     * DOM Level 3: register the given attribute node as an ID attribute     */    public void setIdAttribute(String name, boolean makeId) {        //PENDING    }           /**     * DOM Level 3: register the given attribute node as an ID attribute     */    public void setIdAttributeNode(Attr at, boolean makeId) {        //PENDING    }    /**     * DOM Level 3: register the given attribute node as an ID attribute     */    public void setIdAttributeNS(String namespaceURI, String localName,                                    boolean makeId) {        //PENDING    }         /**         * Method getSchemaTypeInfo.         * @return TypeInfo         */    public TypeInfo getSchemaTypeInfo(){      return null; //PENDING    }    public boolean isId() {        return false; //PENDING    }    private String xmlEncoding;    public String getXmlEncoding( ) {        return xmlEncoding;    }    public void setXmlEncoding( String xmlEncoding ) {        this.xmlEncoding = xmlEncoding;    }    private boolean xmlStandalone;    public boolean getXmlStandalone() {        return xmlStandalone;    }    public void setXmlStandalone(boolean xmlStandalone) throws DOMException {        this.xmlStandalone = xmlStandalone;    }    private String xmlVersion;    public String getXmlVersion() {        return xmlVersion;    }    public void setXmlVersion(String xmlVersion) throws DOMException {        this.xmlVersion = xmlVersion;    }}

⌨️ 快捷键说明

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