Java Map to String mapToString(String itemName, Map map)

Here you can find the source of mapToString(String itemName, Map map)

Description

map To String

License

Apache License

Declaration

private static String mapToString(String itemName, Map map) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.*;

public class Main {
    private static String mapToString(String itemName, Map map) {
        StringBuffer buffer = new StringBuffer("\n\t< " + itemName + " >\n");
        Iterator iterator = map.keySet().iterator();

        for (; iterator.hasNext();) {
            Object key = iterator.next();
            Object value = map.get(key);
            buffer.append("\t\t< ").append(null == key ? "null" : key.toString()).append(" = ")
                    .append(null == value ? "null" : value.toString()).append(" >\n");
        }/*from  w ww.  j  a v a 2 s  .c om*/

        buffer.append("\t< " + itemName + " >");
        return buffer.toString();
    }
}

Related

  1. mapToString(Map map)
  2. mapToString(Map map)
  3. mapToString(Map parameterMap)
  4. mapToString(Map map, String splitter)
  5. mapToString(String aName, Map aMap, String aPrefix, String aSuffix, String aKeyValueSeparator, String anEntrySeparator, String anArrayPrefix, String anArraySuffix, String anArraySeparator, String anEscapeChars, char anEscapeSymbol)
  6. mapToStringArray(Map map)
  7. mapToStringBuilder(Map m)
  8. mapToStringList(Map map, String pairDelimiter, String listDelimiter)
  9. mapToStringMap(final Object map)