Java XML Node Value putAll(final NamedNodeMap dst, final NamedNodeMap src)

Here you can find the source of putAll(final NamedNodeMap dst, final NamedNodeMap src)

Description

Puts all Nodes of the source NamedNodeMap into the destination NamedNodeMap

License

Open Source License

Parameter

Parameter Description
dst the destination NamedNodeMap
src the source NamedNodeMap

Declaration

public final static void putAll(final NamedNodeMap dst, final NamedNodeMap src) 

Method Source Code

//package com.java2s;
/**//from  ww w. java2  s  .  co  m
 * The contents of this file are subject to the Regenstrief Public License
 * Version 1.0 (the "License"); you may not use this file except in compliance with the License.
 * Please contact Regenstrief Institute if you would like to obtain a copy of the license.
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 *
 * Copyright (C) Regenstrief Institute.  All Rights Reserved.
 */

import org.w3c.dom.*;

public class Main {
    /**
     * Puts all Nodes of the source NamedNodeMap into the destination NamedNodeMap
     * 
     * @param dst the destination NamedNodeMap
     * @param src the source NamedNodeMap
     **/
    public final static void putAll(final NamedNodeMap dst, final NamedNodeMap src) {
        final int size = size(src);

        for (int i = 0; i < size; i++) {
            dst.setNamedItemNS(src.item(i));
        }
    }

    /**
     * Retrieves the number of Nodes in the NodeList
     * 
     * @param nodeList the NodeList
     * @return the number of Nodes
     **/
    public final static int size(final NodeList nodeList) {
        return nodeList == null ? 0 : nodeList.getLength();
    }

    /**
     * Retrieves the number of Nodes in the NamedNodeMap
     * 
     * @param nodeMap the NamedNodeMap
     * @return the number of Nodes
     **/
    public final static int size(final NamedNodeMap nodeMap) {
        return nodeMap == null ? 0 : nodeMap.getLength();
    }

    /**
     * Retrieves the number of Nodes in the tree rooted at the given Node
     * 
     * @param node the root Node
     * @return the number of Nodes
     **/
    public final static int size(final Node node) {
        if (node == null) {
            return 0;
        }

        final NodeList children = node.getChildNodes();
        int size = 1;
        for (int i = 0, n = size(children); i < n; i++) {
            size += size(children.item(i));
        }

        return size;
    }
}

Related

  1. getValueByElement(Node node)
  2. getValueByTagName(Node n, String tag)
  3. getValueOfValueNode(Node n)
  4. getValues(Node metric)
  5. nodeToDouble(Node node)
  6. setText(Element parent, String text)
  7. setText(Element parentNode, String data)
  8. setText(Node n, String text)
  9. setText(Node node, String text)