Java Map Copy copyEntries(Map aSource, Map aTarget)

Here you can find the source of copyEntries(Map aSource, Map aTarget)

Description

Recursively copies config entry map from the source to the target.

License

Open Source License

Parameter

Parameter Description
aSource source entry map
aTarget target entry map

Declaration

public static void copyEntries(Map aSource, Map aTarget) 

Method Source Code

//package com.java2s;
/*// ww  w  . jav  a2 s.  com
 * Copyright (c) 2004-2006 Active Endpoints, Inc.
 *
 * This program is licensed under the terms of the GNU General Public License
 * Version 2 (the "License") as published by the Free Software Foundation, and 
 * the ActiveBPEL Licensing Policies (the "Policies").  A copy of the License 
 * and the Policies were distributed with this program.  
 *
 * The License is available at:
 * http: *www.gnu.org/copyleft/gpl.html
 *
 * The Policies are available at:
 * http: *www.activebpel.org/licensing/index.html
 *
 * Unless required by applicable law or agreed to in writing, this program is
 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
 * OF ANY KIND, either express or implied.  See the License and the Policies
 * for specific language governing the use of this program.
 */

import java.util.HashMap;
import java.util.Iterator;

import java.util.Map;

public class Main {
    /**
     * Recursively copies config entry map from the source to the target.
     * @param aSource source entry map
     * @param aTarget target entry map
     */
    public static void copyEntries(Map aSource, Map aTarget) {
        for (Iterator iter = aSource.entrySet().iterator(); iter.hasNext();) {
            Map.Entry entry = (Map.Entry) iter.next();
            Object key = entry.getKey();
            Object value = entry.getValue();

            if (value instanceof Map) {
                Map newCopy = new HashMap();
                copyEntries((Map) value, newCopy);
                aTarget.put(key, newCopy);
            } else {
                aTarget.put(key, value);
            }
        }
    }
}

Related

  1. copy(Map master, Map copy)
  2. copy(Map> original)
  3. copy(Map src, Map dst)
  4. copyAndRemove(Map map, K key)
  5. copyDeep(Map> data)
  6. copyExcludingKeys(Map map, Set excludedKeys)
  7. copyHashMap(HashMap map1, HashMap map2)
  8. copyLowerCaseMap(Map map)
  9. copyMap(Map from, Map to)