List of usage examples for java.util Map keySet
Set<K> keySet();
From source file:Main.java
private static Map canonicalize(Map input) { Map retval = new HashMap(); for (Object key : input.keySet()) { retval.put(key, canonicalize(input.get(key))); }/*www . j ava 2 s . c o m*/ return retval; }
From source file:Main.java
public static Map lowerKeyMap(Map map) { Map<String, Object> lowerKeyMap = new HashMap<String, Object>(); for (Object key : map.keySet()) { if (key instanceof String) { lowerKeyMap.put(((String) key).toLowerCase(), map.get(key)); }//from w ww .j a v a 2 s . co m } return lowerKeyMap; }
From source file:Main.java
public static String map2Str(Map<String, String> map) { StringBuilder sb = new StringBuilder(""); Set<String> keys = map.keySet(); for (String key : keys) sb.append(key + ":" + map.get(key) + ", "); String s = sb.toString().trim(); if (!s.endsWith(",")) return s; else// w w w.j a v a 2s . co m return s.substring(0, s.lastIndexOf(",") - 1); }
From source file:Main.java
public static <K> Map<K, Integer> uniomCounterMap(Map<K, Integer> first, Map<K, Integer> second) { Map<K, Integer> ret = new HashMap<K, Integer>(first); for (K key : second.keySet()) { if (ret.containsKey(key)) { ret.put(key, ret.get(key) + second.get(key)); } else {//from w ww .ja v a 2 s . c o m ret.put(key, second.get(key)); } } return ret; }
From source file:Main.java
/** * Used to convert dasein metadata map into Jade metadata xml *//*from ww w. j a v a2 s . c o m*/ public static String convertMapToXML(Map<String, String> metaData) { String toReturn = ""; for (String key : metaData.keySet()) { toReturn += String.format("<%s>%s</%s>", key, metaData.get(key), key); } return toReturn; }
From source file:Main.java
public static String getReqPama(Map<String, String> params) { StringBuffer sBuffer = new StringBuffer(); Iterator<?> iterator = params.keySet().iterator(); while (iterator.hasNext()) { String key = (String) iterator.next(); sBuffer.append(key + "=" + params.get(key) + "&"); }/* ww w. j a v a 2 s . c o m*/ String reqString = sBuffer.toString(); return reqString.substring(0, reqString.length() - 1); }
From source file:Main.java
public static void dumpThreads() { final Map<Thread, StackTraceElement[]> threads = Thread.getAllStackTraces(); for (Thread thread : threads.keySet()) System.out.println((thread.isDaemon() ? "DAEMON " : " ") + thread.getName()); // final ThreadInfo[] threads = ManagementFactory.getThreadMXBean().dumpAllThreads(false, false); // for(ThreadInfo thread : threads) { // System.out.println(thread.getThreadName() + ": "); // }/*from ww w . jav a2 s . c om*/ }
From source file:Main.java
public static void dumpAllThreadStacks() { System.out.println("stack trace"); Map<Thread, StackTraceElement[]> map = Thread.getAllStackTraces(); for (Thread t : map.keySet()) { StackTraceElement[] elements = map.get(t); System.out.println(t);//from w ww . ja va 2 s . c o m System.out.println("isDaemon : " + t.isDaemon() + ", isAlive : " + t.isAlive() + ", isInterrupted : " + t.isInterrupted()); for (StackTraceElement e : elements) { System.out.println("\t" + e); } System.out.println(""); } }
From source file:Main.java
/** * <p>/*from w w w.j a va 2 s.c om*/ * This method returns the <tt>Iterator</tt> of a passed map instance * </p> * * @param mapObj * A map instance whose iterator needs to be returned * * @return * an instance of <tt>Iterator</tt> */ public static Iterator<? extends Object> getIteratorForMap(Map<? extends Object, ? extends Object> mapObj) { Set<? extends Object> keySet = mapObj.keySet(); return keySet.iterator(); }
From source file:Main.java
public static Bundle mapToBundle(Map<String, String> map) { Bundle bundle = new Bundle(); if (map != null) { for (String key : map.keySet()) { bundle.putString(key, map.get(key)); }/*from w w w . j a v a2 s . co m*/ } return bundle; }