Example usage for java.util HashMap get

List of usage examples for java.util HashMap get

Introduction

In this page you can find the example usage for java.util HashMap get.

Prototype

public V get(Object key) 

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:Main.java

public static boolean isResponseOK(HashMap<String, Object> responseMap) {
    String str = (String) responseMap.get(STATUS);
    if (str.equals(OK))
        return true;
    return false;
}

From source file:Main.java

public static void incrementHashMap(HashMap map, String key, int n) {
    int count;// w  ww  .j  av  a2s  .  com
    Integer countI = (Integer) map.get(key);
    if (countI == null)
        count = 0;
    else {
        count = countI;
    }
    map.put(key, count + n);
}

From source file:Main.java

public static void incrementTwoLevelHashMap(HashMap map, String key1, String key2, int n) {
    HashMap map2 = (HashMap) map.get(key1);
    if (map2 == null) {
        map2 = new HashMap();
        map.put(key1, map2);/*from w w w.jav a  2 s . c o  m*/
    }
    incrementHashMap(map2, key2, n);
}

From source file:Main.java

private static String getHashMapValue(HashMap<Integer, String> hashMap, int number) {
    String result = hashMap.get(number);
    if (TextUtils.isEmpty(result)) {
        List<Integer> numbers = getElement(number);
        result = "";
        for (int i = 0; i < numbers.size(); i++) {
            result += hashMap.get(numbers.get(i)) + "|";
        }/*from w  w w  .ja v a2s .c o  m*/
    }
    return result;
}

From source file:Main.java

public static String gettype(HashMap<String, Object> info) {
    if (info != null) {
        ArrayList replies_tree = (ArrayList) info.get("replies_tree");
        if (replies_tree != null && replies_tree.size() > 0) {
            HashMap<String, Object> answers = (HashMap<String, Object>) replies_tree.get(0);
            if (answers != null) {
                ArrayList classes = (ArrayList) answers.get("answer");
                if (classes != null) {
                    HashMap<String, Object> class1 = (HashMap<String, Object>) classes.get(0);
                    if (class1 != null) {
                        return class1.get("type").toString();
                    }//from  w ww  .  j a v a 2s .  co m
                }

            }

        }

    }

    return null;
}

From source file:at.tuwien.ifs.somtoolbox.util.CollectionUtils.java

public static HashMap<String, Integer> getOrCreateValue(HashMap<Integer, HashMap<String, Integer>> map,
        Integer key) {//from   ww  w  .  j av  a 2  s. c  o m
    if (map.get(key) == null) {
        map.put(key, new HashMap<String, Integer>());
    }
    return map.get(key);
}

From source file:Main.java

private static void addToUsed(HashMap<Integer, Integer> used, Integer key, Integer value) {
    if (used.containsKey(value)) {
        value = used.get(value);
        addToUsed(used, key, value);/*from  w  w w.ja v  a  2 s.  co m*/
    }
    used.put(key, value);
}

From source file:Main.java

public static SpannableStringBuilder getSpannableStringFromList(List<HashMap<String, Object>> list) {
    SpannableStringBuilder ssb = new SpannableStringBuilder("");
    int position = 0;
    for (int i = 0; i < list.size(); i++) {
        HashMap<String, Object> map = list.get(i);
        try {/*from  ww  w.  ja va  2 s  .  c o  m*/
            String st = (String) map.get(RICHTEXT_STRING);
            ssb.append(st);
            int len = st.length();
            if (map.containsKey(RICHTEXT_COLOR)) {
                int color = ((Integer) map.get(RICHTEXT_COLOR)).intValue();
                ssb.setSpan(new ForegroundColorSpan(color), position, position + len,
                        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            }
            if (map.containsKey(RICHTEXT_SIZE)) {
                int size = ((Integer) map.get(RICHTEXT_SIZE)).intValue();
                ssb.setSpan(new AbsoluteSizeSpan(size), position, position + len,
                        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            }
            if (map.containsKey(RICHTEXT_RSIZE)) {
                float size = ((Float) map.get(RICHTEXT_RSIZE)).floatValue();
                ssb.setSpan(new RelativeSizeSpan(size), position, position + len,
                        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            }
            if (map.containsKey(RICHTEXT_DELETE)) {
                ssb.setSpan(new StrikethroughSpan(), position, position + len,
                        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            }
            //              android.text.style.RelativeSizeSpan
            position = position + len;
        } catch (Exception e) {
            return null;
        }
    }
    return ssb;
}

From source file:Main.java

public static ArrayList<ContentValues> removeEntriesWhenPresent(
        HashMap<String, ArrayList<ContentValues>> operationMap, String tableName, String idColumnName) {
    ArrayList<ContentValues> restoreOperations = operationMap.get(tableName);
    if (null == restoreOperations) {
        return null;
    }// w  w  w.  ja  v a2s.co m
    ArrayList<ContentValues> removeOperations = new ArrayList<ContentValues>();
    for (ContentValues restoreCv : restoreOperations) {
        if (restoreCv.containsKey(idColumnName)) {
            removeOperations.add(restoreCv);
        }
    }
    for (ContentValues removeCv : removeOperations) {
        restoreOperations.remove(removeCv);
    }
    return removeOperations;
}

From source file:Main.java

public static HashMap tallyPrint(String phrase) {
    int count = 0;
    HashMap<Character, Integer> fav = new HashMap<Character, Integer>();
    for (int i = 0; i < phrase.length(); i++) {
        if (fav.containsKey(phrase.charAt(i)))
            fav.put(phrase.charAt(i), (fav.get(phrase.charAt(i))) + 1);
        else/*from  ww w.j a  va 2 s .co  m*/
            fav.put(phrase.charAt(i), 1);
    }
    return fav;
}