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


Java Node类代码示例

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


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

示例1: 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

示例2: getLastElementChild

import mf.org.w3c.dom.Node; //导入依赖的package包/类
private Element getLastElementChild(Node n) {
    final Node top = n;
    while (n != null) {
        if (n.getNodeType() == Node.ELEMENT_NODE) {
            return (Element) n;
        }
        Node next = n.getLastChild();
        while (next == null) {         
            if (top == n) {
                break;
            }
            next = n.getPreviousSibling();
            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

示例3: getFirstVisibleChildElement

import mf.org.w3c.dom.Node; //导入依赖的package包/类
/** Finds and returns the first visible child element node. */
public static Element getFirstVisibleChildElement(Node parent) {
    
    // search for node
    Node child = parent.getFirstChild();
    while (child != null) {
        if (child.getNodeType() == Node.ELEMENT_NODE &&
                !isHidden(child)) {
            return (Element)child;
        }
        child = child.getNextSibling();
    }
    
    // not found
    return null;
    
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:18,代码来源:DOMUtil.java

示例4: getLastChildElement

import mf.org.w3c.dom.Node; //导入依赖的package包/类
/**
 * Finds and returns the last child node with the given name and
 * attribute name, value pair.
 */
public static Element getLastChildElement(Node   parent,
        String elemName,
        String attrName,
        String attrValue) {
    
    // search for node
    Node child = parent.getLastChild();
    while (child != null) {
        if (child.getNodeType() == Node.ELEMENT_NODE) {
            Element element = (Element)child;
            if (element.getNodeName().equals(elemName) &&
                    element.getAttribute(attrName).equals(attrValue)) {
                return element;
            }
        }
        child = child.getPreviousSibling();
    }
    
    // not found
    return null;
    
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:27,代码来源:DOMUtil.java

示例5: createDeferredTextNode

import mf.org.w3c.dom.Node; //导入依赖的package包/类
/** Creates a text node in the table. */
public int createDeferredTextNode(String data,
                                  boolean ignorableWhitespace) {

    // create node
    int nodeIndex = createNode(Node.TEXT_NODE);
    int chunk = nodeIndex >> CHUNK_SHIFT;
    int index = nodeIndex & CHUNK_MASK;
    setChunkValue(fNodeValue, data, chunk, index);
    // use extra to store ignorableWhitespace info
    setChunkIndex(fNodeExtra, ignorableWhitespace ?  1 : 0, chunk, index);

    // return node index
    return nodeIndex;

}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:17,代码来源:DeferredDocumentImpl.java

示例6: 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

示例7: 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

示例8: getText

import mf.org.w3c.dom.Node; //导入依赖的package包/类
public String getText()
{
    Node child;
    StringBuffer text = new StringBuffer();
    
    // Find the Text nodes contained within this element and return their
    // concatenated value. Required to go around comments, entities, etc.
    child = getFirstChild();
    while ( child != null )
    {
        if ( child instanceof Text ) {
            text.append(( (Text) child ).getData());
        }
        child = child.getNextSibling();
    }
    return text.toString();
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:18,代码来源:HTMLOptionElementImpl.java

示例9: getNamespaceURI

import mf.org.w3c.dom.Node; //导入依赖的package包/类
/**
    * Returns the namespace URI for the specified prefix at the
    * specified context node.
    *
    * @param node The context node.
    * @param prefix The prefix.
    * @return The namespace URI associated with the prefix, or
    * null if no namespace declaration exists for the prefix.
    */
   public static String getNamespaceURI(Node node, String prefix) {
if (node == null || node.getNodeType() != Node.ELEMENT_NODE) {
    return null;
}

if (prefix.equals("")) {
    if (((Element) node).hasAttribute("xmlns")) {
	return ((Element) node).getAttribute("xmlns");
    }
} else {
    String nsattr = "xmlns:" + prefix;
    if (((Element) node).hasAttribute(nsattr)) {
	return ((Element) node).getAttribute(nsattr);
    }
}

return getNamespaceURI(node.getParentNode(), prefix);
   }
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:28,代码来源:Namespaces.java

示例10: removeChild

import mf.org.w3c.dom.Node; //导入依赖的package包/类
/**
 * Since insertBefore caches the docElement (and, currently, docType),
 * removeChild has to know how to undo the cache
 *
 * REVISIT: According to the spec it is not allowed to alter neither the
 * document element nor the document type in any way
 */
public Node removeChild(Node oldChild) throws DOMException {

    super.removeChild(oldChild);

    // If remove succeeded, un-cache the kid appropriately
    int type = oldChild.getNodeType();
    if(type == Node.ELEMENT_NODE) {
        docElement = null;
    }
    else if (type == Node.DOCUMENT_TYPE_NODE) {
        docType = null;
    }

    return oldChild;

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

示例11: insertCell

import mf.org.w3c.dom.Node; //导入依赖的package包/类
public HTMLElement insertCell( int index )
{
    Node        child;
    HTMLElement    newCell;
    
    newCell = new HTMLTableCellElementImpl( (HTMLDocumentImpl) getOwnerDocument(), "TD" );
    child = getFirstChild();
    while ( child != null ) {
        if ( child instanceof HTMLTableCellElement ) {
            if ( index == 0 ) {
                insertBefore( newCell, child );
                return newCell;
            }
            --index;
        }
        child = child.getNextSibling();
    }
    appendChild( newCell );
    return newCell;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:21,代码来源:HTMLTableRowElementImpl.java

示例12: setStartAfter

import mf.org.w3c.dom.Node; //导入依赖的package包/类
public void setStartAfter(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;
    
    // 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,代码行数:39,代码来源:RangeImpl.java

示例13: splitData

import mf.org.w3c.dom.Node; //导入依赖的package包/类
/**
 * A method to be called when a text node has been split,
 * so that live objects can be notified.
 */
void splitData(Node node, Node newNode, int offset) {
    // notify ranges
    if (ranges != null) {
        notifyRangesSplitData(node, newNode, offset);
    }
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:11,代码来源:DocumentImpl.java

示例14: 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

示例15: cloneNode

import mf.org.w3c.dom.Node; //导入依赖的package包/类
/**
 * Return a duplicate copy of this Element. Note that its children
 * will not be copied unless the "deep" flag is true, but Attributes
 * are <i>always</i> replicated.
 *
 * @see mf.org.w3c.dom.Node#cloneNode(boolean)
 */
public Node cloneNode(boolean deep) {

	ElementImpl newnode = (ElementImpl) super.cloneNode(deep);
	// Replicate NamedNodeMap rather than sharing it.
    if (attributes != null) {
        newnode.attributes = (AttributeMap) attributes.cloneMap(newnode);
    }
	return newnode;

}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:18,代码来源:ElementImpl.java


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