List of usage examples for java.util Map keySet
Set<K> keySet();
From source file:Main.java
public static String mapGetValueIgnoringCase(java.util.Map<String, String> map, String key) { if (map.containsKey(key)) { return map.get(key); }// w w w . j ava 2 s.c o m for (String f : map.keySet()) { if (equalsIgnoreCase(f, key)) { return map.get(f); } } return null; }
From source file:Main.java
/** * Try to find the {@link Document} associated with a certain language * directory path. In case nothing is found, null is returned. * // w ww . java 2s .c o m * @param map * {@link Map} in which the search will be made. * @param languageDirectory * Directory holding the path to be compared, in order to find * the {@link Document} in the given {@link Map}. This Object is * updated with a reference to the object in the {@link Map}. * * @return {@link Document} element associated, in case a match is * successful. */ private static Document findDocumentByLanguageDirectory(Map<File, Document> map, File languageDirectory) { Document document = null; Set<File> languageFolders = map.keySet(); if (languageFolders != null) { for (File languageFolder : languageFolders) { if (languageFolder.getPath().equals(languageDirectory.getPath())) { document = map.get(languageFolder); languageDirectory = languageFolder; break; } } } return document; }
From source file:com.mmd.mssp.util.HttpUtil.java
public static String putParams(String uri, Map<String, String> params) { if (params != null) { Set<String> set = params.keySet(); for (String key : set) { uri = putParam4query(uri, key, params.get(key)); }//w w w . j a v a 2 s . c o m } return uri; }
From source file:Main.java
/** * @author TheMrMilchmann/* w w w . ja v a2 s . c o m*/ * @since DerpieLang v1.0.0 */ @SuppressWarnings("unchecked") public static final <K, V, OK> HashMap<K, V> transform(Map<OK, ?> toTransform) throws IllegalArgumentException { HashMap<K, V> map = new HashMap<K, V>(); try { for (Object key : toTransform.keySet()) { map.put((K) key, (V) toTransform.get((OK) key)); } return map; } catch (Throwable t) { throw new IllegalArgumentException(t); } }
From source file:Main.java
public static Collection<Object> getSortedValues(Map<Integer, Object> vParameters) { if (vParameters == null || vParameters.size() == 0) return null; Set<Integer> keys = vParameters.keySet(); SortedMap<Integer, Object> sortedMap = new TreeMap<Integer, Object>(vParameters); Collection<Object> result = sortedMap.values(); return result; }
From source file:dk.statsbiblioteket.doms.surveillance.surveyor.SurveyorServletUtils.java
/** * Handle actions given a servlet request on a surveyor. * Will handle requests to mark a log message as handled, and requests * never to show a given message again.// w w w . j a v a 2 s . com * @param request The request containing the parameters. * @param surveyor The surveyor to call the actions on. */ public static void handlePostedParameters(HttpServletRequest request, Surveyor surveyor) { log.trace("Enter handlePostedParameters()"); String applicationName; try { request.setCharacterEncoding("UTF-8"); } catch (UnsupportedEncodingException e) { //UTF-8 must be supported as per spec. throw new Error("UTF-8 unsupported by JVM", e); } applicationName = request.getParameter("applicationname"); if (applicationName != null) { Map<String, String[]> parameters = request.getParameterMap(); for (String key : parameters.keySet()) { if (key.startsWith("handle:") && Arrays.equals(new String[] { "Handled" }, parameters.get(key))) { surveyor.markHandled(applicationName, key.substring("handle:".length())); } } if (request.getParameter("notagain") != null) { surveyor.notAgain(applicationName, request.getParameter("notagain")); } } }
From source file:Main.java
public static String getStringByMap(Map<String, Object> map) { StringBuffer sb = new StringBuffer(BUFFER_SIZE); Set<String> keys = map.keySet(); Iterator<String> iter = keys.iterator(); while (iter.hasNext()) { String key = iter.next(); Object value = map.get(key); if (value == null) { continue; }/* ww w. j a va 2s .c o m*/ String clsName = value.getClass().getName(); if (value.getClass().isArray()) { sb.append("[").append(key).append(":").append(ARRAY).append(":") .append(toStringByArray((Object[]) value)).append("]"); } else if (STRING.equals(clsName) || INTEGER.equals(clsName) || LONG.equals(clsName) || BOOLEAN.equals(clsName) || DATE.equals(clsName)) { if ("".equals(value.toString())) { continue; } sb.append("[").append(key).append(":").append(value.getClass().getName()).append(":") .append(esc(value.toString())).append("]"); } } return sb.toString(); }
From source file:Util.java
public static String dump(Map map) { if (map == null) return "null"; StringBuffer buf = new StringBuffer().append('{'); Set keys = map.keySet(); Iterator iterator = keys.iterator(); Object key;/* www . j a va 2 s .c o m*/ Object value; boolean first = true; while (iterator.hasNext()) { if (first) first = false; else buf.append(','); key = iterator.next(); value = map.get(key); buf.append(key + "->" + value); } buf.append('}'); return buf.toString(); }
From source file:Main.java
/** * Returns a cloned Map of String to Set of String. * * @param map Map to be cloned./*from w ww.ja va2 s . c o m*/ * @return cloned map. */ public static Map<String, Set<String>> cloneMap(Map<String, Set<String>> map) { Map<String, Set<String>> clone = new HashMap<String, Set<String>>(); for (String key : map.keySet()) { Set<String> set = new HashSet<String>(); Set<String> orig = (Set<String>) map.get(key); set.addAll(orig); clone.put(key, set); } return clone; }
From source file:com.stratumsoft.xmlgen.SchemaUtil.java
/** * Get the top-level element qname's for the given XmlSchema * * @param xmlSchema/* www. j a va 2 s.c o m*/ * @return */ public static Collection<QName> getElements(XmlSchema xmlSchema) { Collection<QName> elNames = new HashSet<QName>(); if (xmlSchema != null) { Map<QName, XmlSchemaElement> schElems = xmlSchema.getElements(); for (QName name : schElems.keySet()) { elNames.add(name); } } return elNames; }