File src/de/openrat/client/util/MapConverter.java
Last commit: Fri Sep 30 22:45:01 2016 +0200 dankert first version of the java api.
1 package de.openrat.client.util; 2 3 import java.util.ArrayList; 4 import java.util.Iterator; 5 import java.util.List; 6 import java.util.Map; 7 import java.util.Map.Entry; 8 9 public class MapConverter 10 { 11 12 private Map<String, String> map; 13 14 public MapConverter(Map<String, String> map) 15 { 16 super(); 17 this.map = map; 18 } 19 20 public String convertMapToString(String keyValueSeparator, String entrySeparator, boolean withLast) 21 { 22 23 List<String> list = new ArrayList<String>(); 24 25 for (Entry<String, String> entry : map.entrySet()) 26 { 27 list.add(entry.getKey() + keyValueSeparator + entry.getValue()); 28 } 29 30 StringBuffer out = new StringBuffer(); 31 for (Iterator<String> i = list.iterator(); i.hasNext();) 32 { 33 out.append(i.next()); 34 if (withLast || i.hasNext()) 35 { 36 out.append(entrySeparator); 37 } 38 } 39 return out.toString(); 40 41 } 42 }
Downloadsrc/de/openrat/client/util/MapConverter.java
History Fri, 30 Sep 2016 22:45:01 +0200 dankert first version of the java api.