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


Java Node.getParentNode方法代码示例

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


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

示例1: getFirstElementChild

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
private Element getFirstElementChild(Node n) {
    final Node top = n;
    while (n != null) {
        if (n.getNodeType() == Node.ELEMENT_NODE) {
            return (Element) n;
        }
        Node next = n.getFirstChild();
        while (next == null) {         
            if (top == n) {
                break;
            }
            next = n.getNextSibling();
            if (next == null) {
                n = n.getParentNode();
                if (n == null || top == n) {
                    return null;
                }
            }
        }
        n = next;
    }
    return null;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:24,代码来源:ElementImpl.java

示例2: getNextLogicalSibling

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
private Node getNextLogicalSibling(Node n) {
    Node next = n.getNextSibling();
    // If "n" has no following sibling and its parent is an entity reference node we 
    // need to continue the search through the following siblings of the entity 
    // reference as these are logically siblings of the given node.
    if (next == null) {
        Node parent = n.getParentNode();
        while (parent != null && parent.getNodeType() == Node.ENTITY_REFERENCE_NODE) {
            next = parent.getNextSibling();
            if (next != null) {
                break;
            }
            parent = parent.getParentNode();
        }
    }
    return next;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:18,代码来源:ElementImpl.java

示例3: getParentNode

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/** Internal function.
 *  Return the parent Node, from the input node
 *  after applying filter, whatToshow.
 *  The current node is not consulted or set.
 */
Node getParentNode(Node node) {
    
    if (node == null || isSameNode(node, fRoot)) return null;
    
    Node newNode = node.getParentNode();
    if (newNode == null)  return null; 
                    
    int accept = acceptNode(newNode);
    
    if (accept == NodeFilter.FILTER_ACCEPT)
        return newNode;
    else 
    //if (accept == NodeFilter.SKIP_NODE) // and REJECT too.
    {
        return getParentNode(newNode);
    }
    
    
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:25,代码来源:TreeWalkerImpl.java

示例4: isLegalContainer

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Returns true IFF the given node can serve as a container
 * for a range's boundary points.
 */
private boolean isLegalContainer( Node node )
{
	if ( node==null )
		return false;

	while( node!=null )
	{
		switch( node.getNodeType() )
		{
		case Node.ENTITY_NODE:
		case Node.NOTATION_NODE:
		case Node.DOCUMENT_TYPE_NODE:
			return false;
		}
		node = node.getParentNode();
	}

	return true;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:24,代码来源:RangeImpl.java

示例5: setIndex

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
public void setIndex( int index )
{
    Node        parent;
    NodeList    options;
    Node        item;
    
    // Locate the parent SELECT. Note that this OPTION might be inside a
    // OPTGROUP inside the SELECT. Or it might not have a parent SELECT.
    // Everything is possible. If no parent is found, just return.
    parent = getParentNode();
    while ( parent != null && ! ( parent instanceof HTMLSelectElement ) )
        parent = parent.getParentNode();
    if ( parent != null )
    {
        // Use getElementsByTagName() which creates a snapshot of all the
        // OPTION elements under the SELECT. Access to the returned NodeList
        // is very fast and the snapshot solves many synchronization problems.
        // Make sure this OPTION is not replacing itself.
        options = ( (HTMLElement) parent ).getElementsByTagName( "OPTION" );
        if ( options.item( index ) != this )
        {
            // Remove this OPTION from its parent. Place this OPTION right
            // before indexed OPTION underneath it's direct parent (might
            // be an OPTGROUP).
            getParentNode().removeChild( this );
            item = options.item( index );
            item.getParentNode().insertBefore( this, item );
        }
    }
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:31,代码来源:HTMLOptionElementImpl.java

示例6: indexOf

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/** what is the index of the child in the parent */
int indexOf(Node child, Node parent) {
    if (child.getParentNode() != parent) return -1;
    int i = 0;
    for(Node node = parent.getFirstChild(); node!= child; node=node.getNextSibling()) {
        i++;
    }
    return i;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:10,代码来源:RangeImpl.java

示例7: getElementAncestor

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
Node getElementAncestor(Node currentNode) {
    Node parent = currentNode.getParentNode();
    while (parent != null) {
        short type = parent.getNodeType();
        if (type == Node.ELEMENT_NODE) {
            return parent;
        }
        parent = parent.getParentNode();
    }
    return null;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:12,代码来源:NodeImpl.java

示例8: validate

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/** Traverse the DOM and fire events to the schema validator. */
private void validate(Node node) {
    final Node top = node;
    final boolean useIsSameNode = useIsSameNode(top);
    // Performs a non-recursive traversal of the DOM. This
    // will avoid a stack overflow for DOMs with high depth.
    while (node != null) {
        beginNode(node);
        Node next = node.getFirstChild();
        while (next == null) {
            finishNode(node);           
            if (top == node) {
                break;
            }
            next = node.getNextSibling();
            if (next == null) {
                node = node.getParentNode();
                if (node == null || ((useIsSameNode) ? 
                    top.isSameNode(node) : top == node)) {
                    if (node != null) {
                        finishNode(node);
                    }
                    next = null;
                    break;
                }
            }
        }
        node = next;
    }
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:31,代码来源:DOMValidatorHelper.java

示例9: nextNode

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/** The method nextNode(Node, boolean) returns the next node 
 *  from the actual DOM tree.
 * 
 *  The boolean visitChildren determines whether to visit the children.
 *  The result is the nextNode.
 */
Node nextNode(Node node, boolean visitChildren) {
        
    if (node == null) return fRoot;

    Node result;
    // only check children if we visit children.
    if (visitChildren) {
        //if hasChildren, return 1st child.
        if (node.hasChildNodes()) {
            result = node.getFirstChild();
            return result;
        }
    }
        
    if (node == fRoot) { //if Root has no kids
        return null;
    }

    // if hasSibling, return sibling
    result = node.getNextSibling();
    if (result != null) return result;
    
            
    // return parent's 1st sibling.
    Node parent = node.getParentNode();
    while (parent != null && parent != fRoot) {
        result = parent.getNextSibling();
        if (result != null) {
            return result;
        } else {
            parent = parent.getParentNode();
        }
                        
    } // while (parent != null && parent != fRoot) {
    
    // end of list, return null
    return null;            
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:45,代码来源:NodeIteratorImpl.java

示例10: previousNode

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/** The method previousNode(Node) returns the previous node 
 *  from the actual DOM tree.
 */
Node previousNode(Node node) {
    
    Node result;
    
    // if we're at the root, return null.
    if (node == fRoot) return null;
    
    // get sibling
    result = node.getPreviousSibling();
    if (result == null) {
        //if 1st sibling, return parent
        result = node.getParentNode();
        return result;
    }
    
    // if sibling has children, keep getting last child of child.
    if (result.hasChildNodes()
        && !(!fEntityReferenceExpansion
            && result != null
            && result.getNodeType() == Node.ENTITY_REFERENCE_NODE)) 
   
    {
        while (result.hasChildNodes()) {
            result = result.getLastChild();
        }
    }          
        
    return result;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:33,代码来源:NodeIteratorImpl.java

示例11: setRowIndex

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
public void setRowIndex( int rowIndex )
{
    Node    parent;
    
    parent = getParentNode();
    if ( parent instanceof HTMLTableSectionElement ) {
        parent = parent.getParentNode();
    }
    if ( parent instanceof HTMLTableElement ) {
        ( (HTMLTableElementImpl) parent ).insertRowX( rowIndex, this );
    }
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:13,代码来源:HTMLTableRowElementImpl.java

示例12: getPreviousSibling

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/** Internal function.
   *  Return the previousSibling Node, from the input node
   *  after applying filter, whatToshow.
*  NEVER TRAVERSES ABOVE THE SPECIFIED ROOT NODE. 
   *  The current node is not consulted or set.
   */
  Node getPreviousSibling(Node node, Node root) {
      
      if (node == null || isSameNode(node, root)) return null;
      
      Node newNode = node.getPreviousSibling();
      if (newNode == null) {
              
          newNode = node.getParentNode();
          if (newNode == null || isSameNode(newNode, root)) return null; 
              
          int parentAccept = acceptNode(newNode);
              
          if (parentAccept==NodeFilter.FILTER_SKIP) {
              return getPreviousSibling(newNode, root);
          }
          
          return null;
      }
      
      int accept = acceptNode(newNode);
      
      if (accept == NodeFilter.FILTER_ACCEPT)
          return newNode;
      else 
      if (accept == NodeFilter.FILTER_SKIP) {
          Node fChild =  getLastChild(newNode);
          if (fChild == null) {
              return getPreviousSibling(newNode, root);
          }
          return fChild;
      }
      else 
      //if (accept == NodeFilter.REJECT_NODE) 
      {
          return getPreviousSibling(newNode, root);
      }
      
  }
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:45,代码来源:TreeWalkerImpl.java

示例13: getCommonAncestorContainer

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
public Node getCommonAncestorContainer() {
    if ( fDetach ) {
        throw new DOMException(
            DOMException.INVALID_STATE_ERR, 
            DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_STATE_ERR", null));
    }
    ArrayList startV = new ArrayList();
    Node node;
    for (node=fStartContainer; node != null; 
         node=node.getParentNode()) 
    {
        startV.add(node);
    }
    ArrayList endV = new ArrayList();
    for (node=fEndContainer; node != null; 
         node=node.getParentNode()) 
    {
        endV.add(node);
    }
    int s = startV.size()-1;
    int e = endV.size()-1;
    Object result = null;
    while (s>=0 && e>=0) {
        if (startV.get(s) == endV.get(e)) {
            result = startV.get(s);
        } else {
            break;
        }
        --s;
        --e;
    }
    return (Node)result; 
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:34,代码来源:RangeImpl.java

示例14: setStartBefore

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
public void setStartBefore(Node refNode) 
    throws RangeException 
{
    if (fDocument.errorChecking) {
        if (fDetach) {
            throw new DOMException(
                    DOMException.INVALID_STATE_ERR, 
                    DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_STATE_ERR", null));
        }
        if ( !hasLegalRootContainer(refNode) ||
                !isLegalContainedNode(refNode) )
        {
            throw new RangeExceptionImpl(
                    RangeException.INVALID_NODE_TYPE_ERR, 
                    DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_NODE_TYPE_ERR", null));
        }
        if ( fDocument != refNode.getOwnerDocument() && fDocument != refNode) {
            throw new DOMException(
                    DOMException.WRONG_DOCUMENT_ERR,
                    DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null));
        }
    }
	
    fStartContainer = refNode.getParentNode();
    int i = 0;
    for (Node n = refNode; n!=null; n = n.getPreviousSibling()) {
        i++;
    }
    fStartOffset = i-1;
    
    // If one boundary-point of a Range is set to have a root container
    // other
    // than the current one for the Range, the Range should be collapsed to
    // the new position.
    // The start position of a Range should never be after the end position.
    if (getCommonAncestorContainer() == null
            || (fStartContainer == fEndContainer && fEndOffset < fStartOffset)) {
        collapse(true);
    }  
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:41,代码来源:RangeImpl.java

示例15: fillNamespaceContext

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
void fillNamespaceContext() {
    if (fSchemaRoot != null) {
        Node currentNode = fSchemaRoot.getParentNode();
        while (currentNode != null) {
            if (Node.ELEMENT_NODE == currentNode.getNodeType()) {
                NamedNodeMap attributes = currentNode.getAttributes();
                final int attrCount = attributes.getLength();
                for (int i = 0; i < attrCount; ++i) {
                    Attr attr = (Attr) attributes.item(i);
                    String value = attr.getValue();
                    if (value == null) {
                        value = XMLSymbols.EMPTY_STRING;
                    }
                    fillQName(fAttributeQName, attr);
                    // REVISIT: Should we be looking at non-namespace attributes
                    // for additional mappings? Should we detect illegal namespace
                    // declarations and exclude them from the context? -- mrglavas
                    if (fAttributeQName.uri == NamespaceContext.XMLNS_URI) {
                        // process namespace attribute
                        if (fAttributeQName.prefix == XMLSymbols.PREFIX_XMLNS) {
                            declarePrefix(fAttributeQName.localpart, value.length() != 0 ? fSymbolTable.addSymbol(value) : null);
                        }
                        else {
                            declarePrefix(XMLSymbols.EMPTY_STRING, value.length() != 0 ? fSymbolTable.addSymbol(value) : null);
                        }
                    }
                }
                
            }
            currentNode = currentNode.getParentNode();
        }
    }
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:34,代码来源:SchemaNamespaceSupport.java


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