本文整理汇总了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;
}
示例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();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
示例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() );
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例14: getHead
import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/**
* Obtains the <HEAD> element in the document, creating one if does
* not exist before. The <HEAD> element is the first element in the
* <HTML> in the document. The <HTML> 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 <HEAD> element
* correctly placed.
*
* @return The <HEAD> 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;
}
示例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();
}