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


Java Node.getNextSibling方法代码示例

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


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

示例1: getFirstElementChild

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * @see <a href="http://www.w3.org/TR/2008/REC-ElementTraversal-20081222/#attribute-firstElementChild">
 * Element Traversal Specification</a>
 */
public final Element getFirstElementChild() {
    Node n = getFirstChild();
    while (n != null) {
        switch (n.getNodeType()) {
            case Node.ELEMENT_NODE:
                return (Element) n;
            case Node.ENTITY_REFERENCE_NODE:
                final Element e = getFirstElementChild(n);
                if (e != null) {
                    return e;
                }
                break;
        }
        n = n.getNextSibling();
    }
    return null;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:22,代码来源:ElementImpl.java

示例2: deleteRow

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
public synchronized void deleteRow( int index )
{
    Node    child;
    
    child = getFirstChild();
    while ( child != null )
    {
        if ( child instanceof HTMLTableRowElement )
        {
            if ( index == 0 )
            {
                removeChild ( child );
                return;
            }
            --index;
        }
        else
        if ( child instanceof HTMLTableSectionElementImpl )
        {
            index = ( (HTMLTableSectionElementImpl) child ).deleteRowX( index );
            if ( index < 0 )
                return;
        }
        child = child.getNextSibling();
    }
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:27,代码来源:HTMLTableElementImpl.java

示例3: getNextSiblingElementNS

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/** Finds and returns the next sibling node with the given qualified name. */
public static Element getNextSiblingElementNS(Node node,
        String uri, String localpart) {
    
    // search for node
    Node sibling = node.getNextSibling();
    while (sibling != null) {
        if (sibling.getNodeType() == Node.ELEMENT_NODE) {
            String siblingURI = sibling.getNamespaceURI();
            if (siblingURI != null && siblingURI.equals(uri) &&
                    sibling.getLocalName().equals(localpart)) {
                return (Element)sibling;
            }
        }
        sibling = sibling.getNextSibling();
    }
    
    // not found
    return null;
    
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:22,代码来源:DOMUtil.java

示例4: getNextSiblingElement

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Finds and returns the next sibling node with the given name and
 * attribute name, value pair. Since only elements have attributes,
 * the node returned will be of type Node.ELEMENT_NODE.
 */
public static Element getNextSiblingElement(Node   node,
        String elemName,
        String attrName,
        String attrValue) {
    
    // search for node
    Node sibling = node.getNextSibling();
    while (sibling != null) {
        if (sibling.getNodeType() == Node.ELEMENT_NODE) {
            Element element = (Element)sibling;
            if (element.getNodeName().equals(elemName) &&
                    element.getAttribute(attrName).equals(attrValue)) {
                return element;
            }
        }
        sibling = sibling.getNextSibling();
    }
    
    // not found
    return null;
    
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:28,代码来源:DOMUtil.java

示例5: getFirstChildElementNS

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/** Finds and returns the first child node with the given qualified name. */
public static Element getFirstChildElementNS(Node parent,
        String[][] elemNames) {
    
    // search for node
    Node child = parent.getFirstChild();
    while (child != null) {
        if (child.getNodeType() == Node.ELEMENT_NODE) {
            for (int i = 0; i < elemNames.length; i++) {
                String uri = child.getNamespaceURI();
                if (uri != null && uri.equals(elemNames[i][0]) &&
                        child.getLocalName().equals(elemNames[i][1])) {
                    return (Element)child;
                }
            }
        }
        child = child.getNextSibling();
    }
    
    // not found
    return null;
    
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:24,代码来源:DOMUtil.java

示例6: deleteCell

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
public void deleteCell( int index )
{
    Node    child;
    
    child = getFirstChild();
    while ( child != null ) {
        if ( child instanceof HTMLTableCellElement ) {
            if ( index == 0 ) {
                removeChild ( child );
                return;
            }
            --index;
        }
        child = child.getNextSibling();
    }
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:17,代码来源:HTMLTableRowElementImpl.java

示例7: setText

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
public void setText( String text )
{
    Node    child;
    Node    next;
    
    // Delete all the nodes and replace them with a single Text node.
    // This is the only approach that can handle comments and other nodes.
    child = getFirstChild();
    while ( child != null )
    {
        next = child.getNextSibling();
        removeChild( child );
        child = next;
    }
    insertBefore( getOwnerDocument().createTextNode( text ), getFirstChild() );
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:17,代码来源:HTMLScriptElementImpl.java

示例8: isEqualNode

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * DOM Level 3 WD- Experimental.
 * Override inherited behavior from NodeImpl to support deep equal.
 */
public boolean isEqualNode(Node arg) {
    if (!super.isEqualNode(arg)) {
        return false;
    }
    // there are many ways to do this test, and there isn't any way
    // better than another. Performance may vary greatly depending on
    // the implementations involved. This one should work fine for us.
    Node child1 = getFirstChild();
    Node child2 = arg.getFirstChild();
    while (child1 != null && child2 != null) {
        if (!child1.isEqualNode(child2)) {
            return false;
        }
        child1 = child1.getNextSibling();
        child2 = child2.getNextSibling();
    }
    if (child1 != child2) {
        return false;
    }
    return true;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:26,代码来源:ParentNode.java

示例9: getCellIndex

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
public int getCellIndex()
{
    Node    parent;
    Node    child;
    int        index;
    
    parent = getParentNode();
    index = 0;
    if ( parent instanceof HTMLTableRowElement )
    {
        child = parent.getFirstChild();
        while ( child != null )
        {
            if ( child instanceof HTMLTableCellElement )
            {
                if ( child == this )
                    return index;
                ++ index;
            }
            child = child.getNextSibling();
        }
    }
    return -1;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:25,代码来源:HTMLTableCellElementImpl.java

示例10: getNextVisibleSiblingElement

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
public static Element getNextVisibleSiblingElement(Node node) {
    
    // search for node
    Node sibling = node.getNextSibling();
    while (sibling != null) {
        if (sibling.getNodeType() == Node.ELEMENT_NODE &&
                !isHidden(sibling)) {
            return (Element)sibling;
        }
        sibling = sibling.getNextSibling();
    }
    
    // not found
    return null;
    
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:17,代码来源:DOMUtil.java

示例11: deleteRowX

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
int deleteRowX( int index )
{
    Node    child;
    
    child = getFirstChild();
    while ( child != null )
    {
        if ( child instanceof HTMLTableRowElement )
        {
            if ( index == 0 )
            {
                removeChild ( child );
                return -1;
            }
            --index;
        }
        child = child.getNextSibling();
    }
    return index;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:21,代码来源:HTMLTableSectionElementImpl.java

示例12: getTHead

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
public synchronized HTMLTableSectionElement getTHead()
{
    Node    child;
    
    child = getFirstChild();
    while ( child != null )
    {
        if ( child instanceof HTMLTableSectionElement &&
             child.getNodeName().equals( "THEAD" ) )
            return (HTMLTableSectionElement) child;
        child = child.getNextSibling();
    }
    return null;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:15,代码来源:HTMLTableElementImpl.java

示例13: getCaption

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
public synchronized HTMLTableCaptionElement getCaption()
{
    Node    child;
    
    child = getFirstChild();
    while ( child != null )
    {
        if ( child instanceof HTMLTableCaptionElement &&
             child.getNodeName().equals( "CAPTION" ) )
            return (HTMLTableCaptionElement) child;
        child = child.getNextSibling();
    }
    return null;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:15,代码来源:HTMLTableElementImpl.java

示例14: getHead

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Obtains the &lt;HEAD&gt; element in the document, creating one if does
 * not exist before. The &lt;HEAD&gt; element is the first element in the
 * &lt;HTML&gt; in the document. The &lt;HTML&gt; element is obtained by
 * calling {@link #getDocumentElement}. If the element does not exist, one
 * is created.
 * <P>
 * Called by {@link #getTitle}, {@link #setTitle}, {@link #getBody} and
 * {@link #setBody} to assure the document has the &lt;HEAD&gt; element
 * correctly placed.
 *
 * @return The &lt;HEAD&gt; element
 */
public synchronized HTMLElement getHead()
{
    Node    head;
    Node    html;
    Node    child;
    Node    next;

    // Call getDocumentElement() to get the HTML element that is also the
    // top-level element in the document. Get the first element in the
    // document that is called HEAD. Work with that.
    html = getDocumentElement();
    synchronized ( html )
    {
        head = html.getFirstChild();
        while ( head != null && ! ( head instanceof HTMLHeadElement ) )
            head = head.getNextSibling();
        // HEAD exists but might not be first element in HTML: make sure
        // it is and return it.
        if ( head != null )
        {
            synchronized ( head )
            {
                child = html.getFirstChild();
                while ( child != null && child != head )
                {
                    next = child.getNextSibling();
                    head.insertBefore( child, head.getFirstChild() );
                    child = next;
                }
            }
            return (HTMLElement) head;
        }

        // Head does not exist, create a new one, place it at the top of the
        // HTML element and return it.
        head = new HTMLHeadElementImpl( this, "HEAD" );
        html.insertBefore( head, html.getFirstChild() );
    }
    return (HTMLElement) head;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:54,代码来源:HTMLDocumentImpl.java

示例15: toString

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
public String toString(){
	if( fDetach) {
		throw new DOMException(
		DOMException.INVALID_STATE_ERR, 
            DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_STATE_ERR", null));
	}

	Node node = fStartContainer;
    Node stopNode = fEndContainer;
	StringBuffer sb = new StringBuffer();
	if (fStartContainer.getNodeType() == Node.TEXT_NODE
	 || fStartContainer.getNodeType() == Node.CDATA_SECTION_NODE
	) {
	    if (fStartContainer == fEndContainer) {
	        sb.append(fStartContainer.getNodeValue().substring(fStartOffset, fEndOffset));
	        return sb.toString();
        }
	    sb.append(fStartContainer.getNodeValue().substring(fStartOffset));
        node=nextNode (node,true); //fEndContainer!=fStartContainer
	    
	}
    else {  //fStartContainer is not a TextNode
        node=node.getFirstChild();
        if (fStartOffset>0) { //find a first node within a range, specified by fStartOffset
           int counter=0;
           while (counter<fStartOffset && node!=null) {
               node=node.getNextSibling();
               counter++;
           }  
        }
        if (node == null) {
               node = nextNode(fStartContainer,false);
        }
    } 
    if ( fEndContainer.getNodeType()!= Node.TEXT_NODE &&
         fEndContainer.getNodeType()!= Node.CDATA_SECTION_NODE ){
         int i=fEndOffset;
         stopNode = fEndContainer.getFirstChild();
         while( i>0 && stopNode!=null ){
             --i;
             stopNode = stopNode.getNextSibling();
         }
         if ( stopNode == null )
             stopNode = nextNode( fEndContainer, false );
     }
     while (node != stopNode) {  //look into all kids of the Range
         if (node == null) break;
         if (node.getNodeType() == Node.TEXT_NODE
         ||  node.getNodeType() == Node.CDATA_SECTION_NODE) {
             sb.append(node.getNodeValue());
         }

         node = nextNode(node, true);
     }

  	if (fEndContainer.getNodeType() == Node.TEXT_NODE
	 || fEndContainer.getNodeType() == Node.CDATA_SECTION_NODE) {
	    sb.append(fEndContainer.getNodeValue().substring(0,fEndOffset));
	}
	return sb.toString();
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:62,代码来源:RangeImpl.java


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