Java Map Put putMapEntry(Map map, String name, String value)

Here you can find the source of putMapEntry(Map map, String name, String value)

Description

Put name and value pair in map.

License

Open Source License

Parameter

Parameter Description
map The map to populate
name The parameter name
value The parameter value

Declaration

private static void putMapEntry(Map<String, String[]> map, String name, String value) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Map;

public class Main {
    /***//from ww  w. j  a  va  2 s. c om
     * Put name and value pair in map.  When name already exist, add value
     * to array of values.
     *
     * @param map The map to populate
     * @param name The parameter name
     * @param value The parameter value
     */
    private static void putMapEntry(Map<String, String[]> map, String name, String value) {
        String[] newValues = null;
        String[] oldValues = map.get(name);
        if (oldValues == null) {
            newValues = new String[1];
            newValues[0] = value;
        } else {
            newValues = new String[oldValues.length + 1];
            System.arraycopy(oldValues, 0, newValues, 0, oldValues.length);
            newValues[oldValues.length] = value;
        }
        map.put(name, newValues);
    }
}

Related

  1. putMap(Map map, Object... args)
  2. putMap(Map target, Map map)
  3. putMapBoolean(Map params, String key)
  4. putMapBooleanList(Map params, String... keys)
  5. putMapByPair(String pair, Map m)
  6. putMapNotNullKey(Map map, K key, V value)
  7. putMapValue(String path, Object value, Map map)
  8. putModifiedAttribute(Map aMap, String name, Object value)
  9. putMultiEntry(Map map, Iterable keys, V value)