List of usage examples for java.util Map get
V get(Object key);
From source file:Main.java
public static Object get(Class c, Map map) { if (map.keySet().contains(c)) { return map.get(c); }// ww w. java2s . c o m for (Iterator i = map.keySet().iterator(); i.hasNext();) { Class candidateClass = (Class) i.next(); if (candidateClass.isAssignableFrom(c)) { return map.get(candidateClass); } } return null; }
From source file:Main.java
/** * Determine whether the response contains a basic authentication challenge. * @param connection the connection from which the response is extracted. * @return <code>true</code> if the response contains an authentication challenge, <code>false</code> otherwise. */// w w w . j a v a 2s . c o m static boolean hasAuthenticationChallenge(HttpURLConnection connection) { Map<String, List<String>> headers = connection.getHeaderFields(); return headers.get(AUTHENTICATION_CHALLENGE_HEADER) != null; }
From source file:Main.java
private static final void add(Map<Integer, List<String>> mapTo_addTo, int keyNum, String value) { if (mapTo_addTo.containsKey(keyNum)) { mapTo_addTo.get(keyNum).add(value); } else {//w w w .j a v a 2s . co m List<String> strList = new ArrayList<String>(); strList.add(value); mapTo_addTo.put(keyNum, strList); } }
From source file:Main.java
public static Map<String, List<String>> classify(List<Map<String, Object>> result, String key, String key2) { Map<String, List<String>> map = new HashMap<String, List<String>>(); List<String> values = null; for (Map<String, Object> record : result) { String mapKey = String.valueOf(record.get(key)); String mapkey2 = String.valueOf(record.get(key2)); if (!map.containsKey(mapKey)) { values = new LinkedList<String>(); values.add(mapkey2);//from w ww . j a v a 2 s. com } else { map.get(mapKey).add(mapkey2); } map.put(mapKey, values); } return map; }
From source file:Main.java
public static <K, V> Collection<Map<K, V>> filterListMap(Collection<Map<K, V>> unfiltered, final K key, final V value) { return filter(unfiltered, new Predicate<Map<K, V>>() { @Override/*from www . ja v a2s .com*/ public boolean apply(Map<K, V> input) { return Objects.equal(input.get(key), value); } }); }
From source file:Main.java
public static void setTextViewEx(Map<String, Object> m, TextView v, String key, String format) { String s = toString(m.get(key)); v.setText(String.format(format, s)); }
From source file:Main.java
@SuppressWarnings({ "rawtypes" }) private static final int getFreq(final Object obj, final Map freqMap) { Integer count = (Integer) freqMap.get(obj); if (count != null) { return count.intValue(); }//from ww w . ja v a2 s . c om return 0; }
From source file:Main.java
public static String toSafeColumnName(String columnName, Map<String, String> cache) { String cachedName = cache.get(columnName); if (cachedName == null) { String safeColumnName = toSafeColumnName(columnName); cache.put(columnName, safeColumnName); return safeColumnName; } else {//from ww w . jav a 2 s . com return cachedName; } }
From source file:Main.java
public static <T> List<T> unwrap(Map<String, List<T>> response, String key) { if (response != null && response.containsKey(key) && response.get(key) != null) { return response.get(key); } else {/* w w w.ja v a2 s .c o m*/ return new ArrayList<>(); } }
From source file:Main.java
public static <T> List<T> unwrapResponse(Map<String, List<T>> response, String key) { if (response != null && response.containsKey(key) && response.get(key) != null) { return response.get(key); } else {//from w w w. j a v a2s .c o m return new ArrayList<>(); } }