Java Utililty Methods XML Node Clone

List of utility methods to do XML Node Clone

Description

The list of methods to do XML Node Clone are organized into topic(s).

Method

Nclone(final N node)
clone
return (N) node.cloneNode(true);
NodecloneNode(Node node)
Currently only use by GIFStreamMetadata and GIFImageMetadata
if (node == null) {
    return null;
IIOMetadataNode newNode = new IIOMetadataNode(node.getNodeName());
if (node instanceof IIOMetadataNode) {
    IIOMetadataNode iioNode = (IIOMetadataNode) node;
    Object obj = iioNode.getUserObject();
    if (obj instanceof byte[]) {
...
NodecloneNode(Node node, Document doc)
Clones the given DOM node into the given DOM document.
Node clone = null;
switch (node.getNodeType()) {
case Node.ELEMENT_NODE:
    clone = doc.createElement(node.getNodeName());
    NamedNodeMap attrs = node.getAttributes();
    for (int i = 0; i < attrs.getLength(); i++) {
        Node attrNode = attrs.item(i);
        Attr attrClone = doc.createAttribute(attrNode.getNodeName());
...
NodecloneNode(Node node, Document target, boolean deep)
Clone given Node into target Document.
if (target == null || node.getOwnerDocument() == target)
    return node.cloneNode(deep);
else {
    Node newNode;
    int nodeType = node.getNodeType();
    switch (nodeType) {
    case Node.ATTRIBUTE_NODE:
        newNode = target.createAttribute(node.getNodeName());
...
voidcopyGraphicFiles(String baseFilename, String currentDirectory, String fileSeparator, NodeIterator graphicsElements)
copy Graphic Files
Node currentNode = graphicsElements.nextNode();
byte[] buffer = new byte[4096];
int bytes_read;
while (currentNode != null) {
    FileInputStream fis = null;
    FileOutputStream fos = null;
    File fileToCopy = null;
    File copiedFile = null;
...
voidcopyInto(Node src, Node dest)
Copies the source tree into the specified place in a destination tree.
Document factory = dest.getOwnerDocument();
boolean domimpl = factory instanceof DocumentImpl;
Node start = src;
Node parent = src;
Node place = src;
while (place != null) {
    Node node = null;
    int type = place.getNodeType();
...
DocumentcopyNode(Node source)
Copies node and all its children to the new document as root element in the new document
if (source == null) {
    return null;
Document sourceDoc = (source.getNodeType() == Node.DOCUMENT_NODE) ? (Document) source
        : source.getOwnerDocument();
Node rootNode = (source.getNodeType() == Node.DOCUMENT_NODE) ? sourceDoc.getDocumentElement() : source;
Preconditions.checkState(sourceDoc != null);
DOMImplementation domImpl = sourceDoc.getImplementation();
...
NodecopyNode(Node source, Node dest)
Copy one node to another node.
if (source.getNodeType() == Node.TEXT_NODE) {
    Text tn = dest.getOwnerDocument().createTextNode(source.getNodeValue());
    return tn;
Node attr = null;
NamedNodeMap attrs = source.getAttributes();
if (attrs != null) {
    for (int i = 0; i < attrs.getLength(); i++) {
...