Java Map to String mapToStringMap(final Object map)

Here you can find the source of mapToStringMap(final Object map)

Description

map To String Map

License

Open Source License

Declaration

public static Map<String, String> mapToStringMap(final Object map) 

Method Source Code


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

import java.util.HashMap;
import java.util.Map;

public class Main {
    public static Map<String, String> mapToStringMap(final Object map) {
        if (!(map instanceof Map<?, ?>)) {
            throw new IllegalArgumentException(
                    String.format("Cannot cast %s to Map<String, ?>", map.getClass().getName()));
        }//www .j  av  a  2  s.  c o  m

        Map<String, String> strMap = new HashMap<String, String>();
        for (Map.Entry<?, ?> e : ((Map<?, ?>) map).entrySet()) {
            strMap.put(e.getKey().toString(), e.getValue().toString());
        }
        return strMap;
    }
}

Related

  1. mapToString(String aName, Map aMap, String aPrefix, String aSuffix, String aKeyValueSeparator, String anEntrySeparator, String anArrayPrefix, String anArraySuffix, String anArraySeparator, String anEscapeChars, char anEscapeSymbol)
  2. mapToString(String itemName, Map map)
  3. mapToStringArray(Map map)
  4. mapToStringBuilder(Map m)
  5. mapToStringList(Map map, String pairDelimiter, String listDelimiter)
  6. toQueryString(Map ps)
  7. toStr(Map msg)
  8. toString(final Map tokens)
  9. toString(Map varnames_to_Terms)