Example usage for java.util Map get

List of usage examples for java.util Map get

Introduction

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

Prototype

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 <T1, T2, T3> Map<T1, T3> merge(Map<T1, T2> map1, Map<T2, T3> map2, Map<T1, T3> map3) {
    for (Map.Entry<T1, T2> e1 : map1.entrySet()) {
        map3.put(e1.getKey(), map2.get(e1.getValue()));
    }/*  w  w w. ja  va2s  . co m*/
    return map3;
}

From source file:Main.java

/**
 * Parses the _revisions dict from a document into an array of revision ID strings
 *//*from  w  ww  . j  av  a  2 s.  co m*/
public static List<String> parseCouchDBRevisionHistory(Map<String, Object> docProperties) {
    Map<String, Object> revisions = (Map<String, Object>) docProperties.get("_revisions");
    if (revisions == null) {
        return null;
    }
    List<String> revIDs = (List<String>) revisions.get("ids");
    Integer start = (Integer) revisions.get("start");
    if (start != null) {
        for (int i = 0; i < revIDs.size(); i++) {
            String revID = revIDs.get(i);
            revIDs.set(i, Integer.toString(start--) + "-" + revID);
        }
    }
    return revIDs;
}

From source file:Main.java

private static String getStringValue(String attrName, Map<String, String> runtimeAttributes, Node docElement) {
    String stringValue = runtimeAttributes.get(attrName);
    if (stringValue == null) {
        Node staleNode = docElement.getAttributes().getNamedItem(attrName);
        if (staleNode != null) {
            stringValue = staleNode.getNodeValue();
        }//from  w w  w  .j  av  a 2 s .  com
    }
    return stringValue;
}

From source file:Main.java

/***
 *
 * @param pressingLength model's length of pause between clicks (x)
 * @return Mx's values List, for My use ALPHA = 1
 *//*from   w  ww  .  ja  va 2  s . c  om*/
private static double M(Map<String, Long> pressingLength) {
    double x = 0;
    for (String key : pressingLength.keySet()) {
        x += pressingLength.get(key);
    }
    return x / pressingLength.size();
}

From source file:Main.java

public static <K> void aggregateMaps(Map<K, Integer> A, Map<K, Integer> B) {
    for (K k : B.keySet()) {
        if (A.containsKey(k))
            A.put(k, A.get(k) + B.get(k));
        else//  www  . j a v  a 2 s .co m
            A.put(k, B.get(k));
    }
}

From source file:com.github.ipaas.ifw.front.directive.DirectiveUtils.java

static String getRequiredParam(Map params, String key) throws TemplateException {
    Object value = params.get(key);
    if (value == null || StringUtils.isEmpty(value.toString())) {
        throw new TemplateModelException("not found required parameter:" + key + " for directive");
    }//from  w  w  w  . j av a 2s .  co  m
    return value.toString();
}

From source file:Main.java

public static Object getJsonValue(String jsonStr, String key) {
    Object rulsObj = null;/*from   w  ww  .j ava  2  s  .c  om*/
    Map<?, ?> rulsMap = jsonToMap(jsonStr);
    if (rulsMap != null && rulsMap.size() > 0) {
        rulsObj = rulsMap.get(key);
    }
    return rulsObj;
}

From source file:Main.java

public static Map<String, Object> getProps(Map<String, Object> map) {
    @SuppressWarnings("unchecked")
    Map<String, Object> props = (Map<String, Object>) map.get(DEFAULT_PROP_KEY);
    if (null == props) {
        props = getHashMap();//from w  w w  .j  a va  2 s  .  co m
        map.put(DEFAULT_PROP_KEY, props);
    }
    return props;
}

From source file:Main.java

/**
 * @return/* ww  w  .  j  av a2s.  co  m*/
 */
public static String getBasePath() {
    Map<String, Object> map = threadLocal.get();
    if (map == null) {
        return null;
    }
    Object o = map.get(BASEPATH_KEY);
    return o == null ? null : o.toString();
}

From source file:Main.java

public static <K, V> List<V> extractValuesInOrder(Map<K, V> map, List<K> keysList) {
    List<V> vals = new LinkedList<V>();
    for (K key : keysList) {
        vals.add(map.get(key));
    }//  www .  ja va  2  s  . co m
    return vals;
}