List of usage examples for java.util Map keySet
Set<K> keySet();
From source file:Main.java
/** * Delete all the keys with null values of the map received * @param map Map<String, Object> map to clean *///w ww .ja v a2s . c o m public static void cleanMapNullValues(Map<String, Object> map) { //check map is null if (map == null) { return; } for (String key : new ArrayList<>(map.keySet())) { if (map.get(key) == null) { map.remove(key); } } }
From source file:com.garyclayburg.BootVaadin.java
public static void dumpSystemProperties() { log.info("system properties dump"); Properties systemProperties = System.getProperties(); TreeMap tm = new TreeMap(systemProperties); for (Object o : tm.keySet()) { String key = (String) o; log.info(key + ": " + tm.get(o)); }/*from w ww. ja v a2 s. c om*/ Map<String, String> getenv = new TreeMap<>(System.getenv()); log.info("system environment dump"); for (String key : getenv.keySet()) { log.info("env " + key + ": " + getenv.get(key)); } }
From source file:Main.java
/** * Returns the string that represents the content of a given style map. * @param styleMap Map with the styles values * @return string that represents the style. *///w w w .jav a 2s . co m public static String getStyleString(Map<String, Object> styleMap, String asig) { String style = ""; Iterator<Object> it = styleMap.values().iterator(); Iterator<String> kit = styleMap.keySet().iterator(); while (kit.hasNext()) { String key = kit.next(); Object value = it.next(); style = style + key + asig + value + ";"; } return style; }
From source file:Main.java
public static Bundle mapToBundle(Map<String, Serializable> map) { Bundle result = new Bundle(); if (map == null) return result; for (String key : map.keySet()) { result.putSerializable(key, map.get(key)); }/*from w ww. j av a 2 s . c om*/ return result; }
From source file:cn.teamlab.wg.framework.struts2.breadcrumb.Utils.java
@SuppressWarnings("rawtypes") public static boolean compareParametersMap(Map m1, Map m2) { if (m1.size() != m2.size()) return false; for (Object key : m1.keySet()) { String[] v1 = (String[]) m1.get(key); String[] v2 = (String[]) m2.get(key); if (v1.length != v2.length) return false; // XXX should values be sorted first ? // FIXME take care of null values ? for (int i = 0; i < v2.length; i++) { if (!v1[i].equals(v2[i])) return false; }//from w ww .jav a 2 s . c om } return true; }
From source file:com.ultrapower.eoms.common.plugin.ecside.common.HTMLOptionsUtil.java
public static String getOptionsList(Map imap,Object defaultKey ,String otherAttribute){ StringBuffer rs=new StringBuffer(); Iterator itor=imap.keySet().iterator(); //from www .ja va 2s.c o m while (itor.hasNext()){ // String key=(String)itor.next(); // String value=(String)imap.get(key); String key=String.valueOf(itor.next()); String value=convertString(imap.get(key),""); String selected=""; if (key.equals(defaultKey)){ selected="selected=\"selected\""; } otherAttribute=StringUtils.isBlank(otherAttribute)?"":" "+otherAttribute+" "; rs.append("<option value=\"").append(key).append("\" ").append(selected).append(otherAttribute).append(" >") .append(value).append("</option>\n"); } return rs.toString(); }
From source file:Main.java
public static String map2String(Map<String, String> map) { StringBuilder result = new StringBuilder(); if (map == null || map.size() == 0) return ""; for (String key : map.keySet()) { result.append(key).append("=").append(map.get(key)).append("&"); }//from w w w. j a v a2 s . c o m return result.substring(0, result.length() - 1); }
From source file:Main.java
/** * //from www . ja v a 2 s . c o m * pre: takes a valid resultSet List, a columnName to group by, a valid * comparator for the columnName's value<br> * post: separates the list into a List of List with each sub-list having the * same columnName value sorted by the keyComparator * * @param resultSet * @param columnName * @param keyComparator * @return null if resultSet is null */ @SuppressWarnings("rawtypes") public static List<List<Map>> splitSqlList(List<Map> resultSet, String columnName, Comparator keyComparator) { if (resultSet == null) return null; Map<Object, List<Map>> map = sqlMapListToMap(resultSet, columnName); Set keys = map.keySet(); Object[] keyArray = keys.toArray(); if (keyComparator == null) { Arrays.sort(keyArray); } else { Arrays.sort(keyArray, keyComparator); } List<List<Map>> rs = new ArrayList<List<Map>>(keyArray.length); for (Object key : keyArray) { rs.add(map.get(key)); } return rs; }
From source file:TokenizerUtil.java
public static String convertMapToCSVString(Map<String, String> urlDefaultMap) { StringBuffer sb = new StringBuffer(); Iterator<String> it = urlDefaultMap.keySet().iterator(); while (it.hasNext()) { if (sb.length() > 0) { sb.append("|"); }//ww w . java 2 s.com String jdbcDriver = it.next(); String defaultURL = urlDefaultMap.get(jdbcDriver); sb.append(jdbcDriver + "|" + defaultURL); } return sb.toString(); }
From source file:jef.common.Entry.java
public static <K, V> List<Entry<K, V>> fromMap(Map<K, V> map) { List<Entry<K, V>> list = new ArrayList<Entry<K, V>>(); for (K k : map.keySet()) { list.add(new Entry<K, V>(k, map.get(k))); }//from w ww . j ava2 s.c o m return list; }