Java Code Examples for com.gargoylesoftware.htmlunit.html.DomNode#getDescendants()

The following examples show how to use com.gargoylesoftware.htmlunit.html.DomNode#getDescendants() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Document.java    From htmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * Imports a node from another document to this document.
 * The source node is not altered or removed from the original document;
 * this method creates a new copy of the source node.
 *
 * @param importedNode the node to import
 * @param deep Whether to recursively import the subtree under the specified node; or not
 * @return the imported node that belongs to this Document
 */
@JsxFunction
public Object importNode(final Node importedNode, final boolean deep) {
    DomNode domNode = importedNode.getDomNodeOrDie();
    domNode = domNode.cloneNode(deep);
    domNode.processImportNode(this);
    for (final DomNode childNode : domNode.getDescendants()) {
        childNode.processImportNode(this);
    }
    return domNode.getScriptableObject();
}
 
Example 2
Source File: Node.java    From htmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a DOM node to the node.
 * @param childObject the node to add to this node
 * @return the newly added child node
 */
@JsxFunction
public Object appendChild(final Object childObject) {
    Object appendedChild = null;
    if (childObject instanceof Node) {
        final Node childNode = (Node) childObject;

        // is the node allowed here?
        if (!isNodeInsertable(childNode)) {
            throw asJavaScriptException(
                new DOMException("Node cannot be inserted at the specified point in the hierarchy",
                    DOMException.HIERARCHY_REQUEST_ERR));
        }

        // Get XML node for the DOM node passed in
        final DomNode childDomNode = childNode.getDomNodeOrDie();

        // Get the parent XML node that the child should be added to.
        final DomNode parentNode = getDomNodeOrDie();

        // Append the child to the parent node
        parentNode.appendChild(childDomNode);
        appendedChild = childObject;

        initInlineFrameIfNeeded(childDomNode);
        for (final DomNode domNode : childDomNode.getDescendants()) {
            initInlineFrameIfNeeded(domNode);
        }
    }
    return appendedChild;
}
 
Example 3
Source File: Document.java    From HtmlUnit-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Imports a node from another document to this document.
 * The source node is not altered or removed from the original document;
 * this method creates a new copy of the source node.
 *
 * @param importedNode the node to import
 * @param deep Whether to recursively import the subtree under the specified node; or not
 * @return the imported node that belongs to this Document
 */
@JsxFunction
public Object importNode(final Node importedNode, final boolean deep) {
    DomNode domNode = importedNode.getDomNodeOrDie();
    domNode = domNode.cloneNode(deep);
    domNode.processImportNode(this);
    for (final DomNode childNode : domNode.getDescendants()) {
        childNode.processImportNode(this);
    }
    return domNode.getScriptableObject();
}
 
Example 4
Source File: Node.java    From HtmlUnit-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a DOM node to the node.
 * @param childObject the node to add to this node
 * @return the newly added child node
 */
@JsxFunction
public Object appendChild(final Object childObject) {
    Object appendedChild = null;
    if (childObject instanceof Node) {
        final Node childNode = (Node) childObject;

        // is the node allowed here?
        if (!isNodeInsertable(childNode)) {
            throw asJavaScriptException(
                new DOMException("Node cannot be inserted at the specified point in the hierarchy",
                    DOMException.HIERARCHY_REQUEST_ERR));
        }

        // Get XML node for the DOM node passed in
        final DomNode childDomNode = childNode.getDomNodeOrDie();

        // Get the parent XML node that the child should be added to.
        final DomNode parentNode = getDomNodeOrDie();

        // Append the child to the parent node
        parentNode.appendChild(childDomNode);
        appendedChild = childObject;

        initInlineFrameIfNeeded(childDomNode);
        for (final DomNode domNode : childDomNode.getDescendants()) {
            initInlineFrameIfNeeded(domNode);
        }
    }
    return appendedChild;
}
 
Example 5
Source File: AbstractList.java    From htmlunit with Apache License 2.0 2 votes vote down vote up
/**
 * Gets the DOM node that have to be examined to see if they are matching.
 * Default implementation looks at all descendants of reference node.
 * @return the nodes
 */
protected Iterable<DomNode> getCandidates() {
    final DomNode domNode = getDomNodeOrNull();
    return domNode.getDescendants();
}
 
Example 6
Source File: XMLDOMNodeList.java    From htmlunit with Apache License 2.0 2 votes vote down vote up
/**
 * Gets the DOM node that have to be examined to see if they are matching.
 * Default implementation looks at all descendants of reference node.
 * @return the nodes
 */
protected Iterable<DomNode> getCandidates() {
    final DomNode domNode = getDomNodeOrNull();
    return domNode.getDescendants();
}
 
Example 7
Source File: AbstractList.java    From HtmlUnit-Android with Apache License 2.0 2 votes vote down vote up
/**
 * Gets the DOM node that have to be examined to see if they are matching.
 * Default implementation looks at all descendants of reference node.
 * @return the nodes
 */
protected Iterable<DomNode> getCandidates() {
    final DomNode domNode = getDomNodeOrNull();
    return domNode.getDescendants();
}
 
Example 8
Source File: XMLDOMNodeList.java    From HtmlUnit-Android with Apache License 2.0 2 votes vote down vote up
/**
 * Gets the DOM node that have to be examined to see if they are matching.
 * Default implementation looks at all descendants of reference node.
 * @return the nodes
 */
protected Iterable<DomNode> getCandidates() {
    final DomNode domNode = getDomNodeOrNull();
    return domNode.getDescendants();
}