当前位置: 首页>>代码示例>>Java>>正文


Java Node.COMMENT_NODE属性代码示例

本文整理汇总了Java中mf.org.w3c.dom.Node.COMMENT_NODE属性的典型用法代码示例。如果您正苦于以下问题:Java Node.COMMENT_NODE属性的具体用法?Java Node.COMMENT_NODE怎么用?Java Node.COMMENT_NODE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在mf.org.w3c.dom.Node的用法示例。


在下文中一共展示了Node.COMMENT_NODE属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkIndex

void checkIndex(Node refNode, int offset) throws DOMException
{
    if (offset < 0) {
        throw new DOMException(
            DOMException.INDEX_SIZE_ERR, 
            DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INDEX_SIZE_ERR", null));
	}

    int type = refNode.getNodeType();
    
    // If the node contains text, ensure that the
    // offset of the range is <= to the length of the text
    if (type == Node.TEXT_NODE
        || type == Node.CDATA_SECTION_NODE
        || type == Node.COMMENT_NODE
        || type == Node.PROCESSING_INSTRUCTION_NODE) {
        if (offset > refNode.getNodeValue().length()) {
            throw new DOMException(DOMException.INDEX_SIZE_ERR, 
            DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INDEX_SIZE_ERR", null));
        }
    }
    else {
        // Since the node is not text, ensure that the offset
        // is valid with respect to the number of child nodes
        if (offset > refNode.getChildNodes().getLength()) {
		throw new DOMException(DOMException.INDEX_SIZE_ERR, 
            DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INDEX_SIZE_ERR", null));
        }
    }
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:30,代码来源:RangeImpl.java

示例2: hasTextContent

final boolean hasTextContent(Node child) {
    return child.getNodeType() != Node.COMMENT_NODE &&
        child.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE &&
        (child.getNodeType() != Node.TEXT_NODE ||
         ((TextImpl) child).isIgnorableWhitespace() == false);
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:6,代码来源:ParentNode.java

示例3: beginNode

/** Do processing for the start of a node. */
private void beginNode(Node node) {
    switch (node.getNodeType()) {
        case Node.ELEMENT_NODE:
            fCurrentElement = node;
            // push namespace context
            fNamespaceContext.pushContext();
            // start element
            fillQName(fElementQName, node);
            processAttributes(node.getAttributes());
            fSchemaValidator.startElement(fElementQName, fAttributes, null);
            break;
        case Node.TEXT_NODE:
            if (fDOMValidatorHandler != null) {
                fDOMValidatorHandler.setIgnoringCharacters(true);
                sendCharactersToValidator(node.getNodeValue());
                fDOMValidatorHandler.setIgnoringCharacters(false);
                fDOMValidatorHandler.characters((Text) node);
            }
            else {
                sendCharactersToValidator(node.getNodeValue());
            }
            break;
        case Node.CDATA_SECTION_NODE:
            if (fDOMValidatorHandler != null) {
                fDOMValidatorHandler.setIgnoringCharacters(true);
                fSchemaValidator.startCDATA(null);
                sendCharactersToValidator(node.getNodeValue());
                fSchemaValidator.endCDATA(null);
                fDOMValidatorHandler.setIgnoringCharacters(false);
                fDOMValidatorHandler.cdata((CDATASection) node);
            }
            else {
                fSchemaValidator.startCDATA(null);
                sendCharactersToValidator(node.getNodeValue());
                fSchemaValidator.endCDATA(null); 
            }
            break;
        case Node.PROCESSING_INSTRUCTION_NODE:
            /** 
             * The validator does nothing with processing instructions so bypass it.
             * Send the ProcessingInstruction node directly to the result builder.
             */
            if (fDOMValidatorHandler != null) {
                fDOMValidatorHandler.processingInstruction((ProcessingInstruction) node);
            }
            break;
        case Node.COMMENT_NODE:
            /** 
             * The validator does nothing with comments so bypass it.
             * Send the Comment node directly to the result builder.
             */
            if (fDOMValidatorHandler != null) {
                fDOMValidatorHandler.comment((Comment) node);
            }
            break;
        case Node.DOCUMENT_TYPE_NODE:
            /** 
             * Send the DocumentType node directly to the result builder.
             */
            if (fDOMValidatorHandler != null) {
                fDOMValidatorHandler.doctypeDecl((DocumentType) node);
            }
            break;
        default: // Ignore other node types.
            break;
    }
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:68,代码来源:DOMValidatorHelper.java

示例4: traverseNode

/**
 * Utility method for traversing a single node.
 * Does not properly handle a text node containing both the
 * start and end offsets.  Such nodes should
 * have been previously detected and been routed to traverseCharacterDataNode.
 * 
 * @param n      The node to be traversed.
 * 
 * @param isFullySelected
 *               Set to true if the node is fully selected.  Should be 
 *               false otherwise.
 *               Note that although the DOM 2 specification says that a 
 *               text node that is boththe start and end container is not
 *               selected, we treat it here as if it were partially 
 *               selected.
 * 
 * @param isLeft Is true if we are traversing the node as part of navigating
 *               the "left boundary" of the range.  If this value is false,
 *               it implies we are navigating the "right boundary" of the
 *               range.
 * 
 * @param how    Specifies what type of traversal is being
 *               requested (extract, clone, or delete).
 *               Legal values for this argument are:
 *               
 *               <ol>
 *               <li><code>EXTRACT_CONTENTS</code> - will simply
 *               return the original node.
 *               
 *               <li><code>CLONE_CONTENTS</code> - will leave the
 *               context tree of the range undisturbed, but will
 *               return a cloned node.
 *               
 *               <li><code>DELETE_CONTENTS</code> - will delete the
 *               node from it's parent, but will return null.
 *               </ol>
 * 
 * @return Returns a node that is the result of visiting the node.
 *         If the traversal operation is
 *         <code>DELETE_CONTENTS</code> the return value is null.
 */
private Node traverseNode( Node n, boolean isFullySelected, boolean isLeft, int how )
{
    if ( isFullySelected ) {
        return traverseFullySelected( n, how );
    }
    final short nodeType = n.getNodeType();
    if (nodeType == Node.TEXT_NODE ||
        nodeType == Node.CDATA_SECTION_NODE ||
        nodeType == Node.COMMENT_NODE ||
        nodeType == Node.PROCESSING_INSTRUCTION_NODE) {
        return traverseCharacterDataNode( n, isLeft, how );
    }
    return traversePartiallySelected( n, how );
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:55,代码来源:RangeImpl.java

示例5: getNodeType

/** 
 * A short integer indicating what type of node this is. The named
 * constants for this value are defined in the org.w3c.dom.Node interface.
 */
public short getNodeType() {
    return Node.COMMENT_NODE;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:7,代码来源:CommentImpl.java


注:本文中的mf.org.w3c.dom.Node.COMMENT_NODE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。