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

The following examples show how to use com.gargoylesoftware.htmlunit.html.DomNode#cloneNode() . 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
/**
 * Clones this node.
 * @param deep if {@code true}, recursively clones all descendants
 * @return the newly cloned node
 */
@JsxFunction
public Object cloneNode(final boolean deep) {
    final DomNode domNode = getDomNodeOrDie();
    final DomNode clonedNode = domNode.cloneNode(deep);

    final Node jsClonedNode = getJavaScriptNode(clonedNode);
    return jsClonedNode;
}
 
Example 3
Source File: XMLDOMNode.java    From htmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * Clones a new node.
 * @param deep flag that indicates whether to recursively clone all nodes that are descendants of this node;
 *     if {@code true}, creates a clone of the complete tree below this node,
 *     if {@code false}, clones this node and its attributes only
 * @return the newly created clone node
 */
@JsxFunction
public Object cloneNode(final boolean deep) {
    final DomNode domNode = getDomNodeOrDie();
    final DomNode clonedNode = domNode.cloneNode(deep);

    final XMLDOMNode jsClonedNode = getJavaScriptNode(clonedNode);
    return jsClonedNode;
}
 
Example 4
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 5
Source File: Node.java    From HtmlUnit-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Clones this node.
 * @param deep if {@code true}, recursively clones all descendants
 * @return the newly cloned node
 */
@JsxFunction
public Object cloneNode(final boolean deep) {
    final DomNode domNode = getDomNodeOrDie();
    final DomNode clonedNode = domNode.cloneNode(deep);

    final Node jsClonedNode = getJavaScriptNode(clonedNode);
    return jsClonedNode;
}
 
Example 6
Source File: XMLDOMNode.java    From HtmlUnit-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Clones a new node.
 * @param deep flag that indicates whether to recursively clone all nodes that are descendants of this node;
 *     if {@code true}, creates a clone of the complete tree below this node,
 *     if {@code false}, clones this node and its attributes only
 * @return the newly created clone node
 */
@JsxFunction
public Object cloneNode(final boolean deep) {
    final DomNode domNode = getDomNodeOrDie();
    final DomNode clonedNode = domNode.cloneNode(deep);

    final XMLDOMNode jsClonedNode = getJavaScriptNode(clonedNode);
    return jsClonedNode;
}