Example usage for java.util HashMap put

List of usage examples for java.util HashMap put

Introduction

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

Prototype

public V put(K key, V value) 

Source Link

Document

Associates the specified value with the specified key in this map.

Usage

From source file:de.taimos.dvalin.interconnect.core.spring.DaemonMessageSender.java

private static HashMap<String, Object> wrapHeaders(final DaemonMessageSenderHeader... headers) {
    final HashMap<String, Object> h = new HashMap<>(headers.length);
    for (final DaemonMessageSenderHeader header : headers) {
        h.put(header.getField().getName(), header.getValue());
    }/* w w w . java 2  s. c  o  m*/
    return h;
}

From source file:jp.mamesoft.mailsocketchat.Mailsocketchat.java

static void userchange(JSONObject jsondata) {
    int id = jsondata.getInt("id");
    Boolean rom = jsondata.getBoolean("rom");
    String ip = jsondata.getString("ip");
    String ua = jsondata.getString("ua");
    HashMap<String, String> userinfo = new HashMap<String, String>();
    userinfo.put("ip", ip);
    userinfo.put("ua", ua);
    if (rom) {/*from   w  w  w . j a  v a 2s .  co m*/
        roms.put(id, userinfo);
        if (users.containsKey(id)) {
            users.remove(id);
        }
    } else {
        String name = jsondata.getString("name");
        userinfo.put("name", name);
        users.put(id, userinfo);
        if (roms.containsKey(id)) {
            roms.remove(id);
        }
    }
}

From source file:com.soomla.store.domain.data.BalanceDrivenPriceModel.java

/**
 * Creates a {@link BalanceDrivenPriceModel} with the given JSONObject.
 * @param jsonObject is a JSONObject representation of the required {@link BalanceDrivenPriceModel}.
 * @return an instance of {@link BalanceDrivenPriceModel}.
 * @throws JSONException//  www .j  a v a2 s  .  co m
 */
public static BalanceDrivenPriceModel fromJSONObject(JSONObject jsonObject) throws JSONException {
    JSONArray valuesPerBalanceJSON = jsonObject.getJSONArray(JSONConsts.GOOD_PRICE_MODEL_VALUES);
    ArrayList<HashMap<String, Integer>> valuesPerBalance = new ArrayList<HashMap<String, Integer>>(
            valuesPerBalanceJSON.length());
    for (int i = 0; i < valuesPerBalanceJSON.length(); i++) {
        JSONObject valuesJSON = valuesPerBalanceJSON.getJSONObject(i);
        Iterator<?> valuesKeys = valuesJSON.keys();
        HashMap<String, Integer> values = new HashMap<String, Integer>();
        while (valuesKeys.hasNext()) {
            String key = (String) valuesKeys.next();
            values.put(key, valuesJSON.getInt(key));
        }

        valuesPerBalance.add(i, values);
    }

    return new BalanceDrivenPriceModel(valuesPerBalance);
}

From source file:ether.RDFHelper.java

private static HashMap<String, String> createMap_pollutantDaily() {
    HashMap<String, String> map = new HashMap<String, String>();
    map.put("ypm10", "PM10");
    return map;/*from   ww w . j  a  v  a 2  s . c om*/
}

From source file:ddf.mime.custom.CustomMimeTypeResolver.java

public static <K, V> HashMap<V, K> reverse(Map<K, V> map) {
    HashMap<V, K> rev = new HashMap<V, K>();
    for (Map.Entry<K, V> entry : map.entrySet()) {
        rev.put(entry.getValue(), entry.getKey());
    }/*w  w w . j  av  a2  s  .  c  o m*/
    return rev;
}

From source file:Main.java

public static HashMap<String, String> JSONObject2Map(JSONObject jsonObject) {
    HashMap<String, String> responseMap = new HashMap<String, String>();

    try {/*from   w w  w .j a  v  a 2s. co m*/
        @SuppressWarnings("unchecked")
        Iterator<String> keys = jsonObject.keys();
        while (keys.hasNext()) {
            String key = (String) keys.next();
            responseMap.put(key, jsonObject.getString(key));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    return responseMap;
}

From source file:mobile.vo.rns.RequireDetailVO.java

public static RequireDetailVO create(Require po) {
    ObjectMapper objectMapper = JackJsonUtil.getMapperInstance(false);
    RequireDetailVO vo = new RequireDetailVO();

    vo.setId(po.getId());//from w w  w.j  av  a 2s  .  c  om

    SkillTag industry = po.getIndustry();
    if (null != industry) {
        vo.setIndustryId(industry.getId());
        vo.setIndustryName(industry.getTagName());
    }

    vo.setTitle(po.getTitle());
    vo.setInfo(po.getInfo());

    if (null == po.getBudget()) {
        vo.setBudget("-1"); // -1 - ?
    } else {
        vo.setBudget(new BigDecimal(po.getBudget()).setScale(1, BigDecimal.ROUND_HALF_UP).toString());
    }

    vo.setCreateDate(new DateTime(po.getCreateDate()).toString("yyyy-MM-dd HH:mm:ss"));

    if (StringUtils.isNotBlank(po.getTags())) {
        try {
            @SuppressWarnings("unchecked")
            List<String> readValue = objectMapper.readValue(po.getTags(), List.class);
            vo.setTags(readValue);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    Iterator<AttachOfRequire> iterator = po.getCaseAttachs().iterator();
    while (iterator.hasNext()) {
        AttachOfRequire attachOfRequire = iterator.next();
        HashMap<String, Object> pair = new HashMap<String, Object>();
        pair.put("attachId", attachOfRequire.id);
        pair.put("filename", attachOfRequire.fileName);
        pair.put("url", Assets.at(attachOfRequire.path));
        vo.getAttachs().add(pair);
    }

    Expert ownerExpert = po.getOwner().getExperts().iterator().next();
    vo.setOwner(User.create(ownerExpert));

    return vo;
}

From source file:ether.RDFHelper.java

private static HashMap<String, String> createMap_pollutantHourly() {
    HashMap<String, String> map = new HashMap<String, String>();
    map.put("so2", "SulphurDioxide");
    map.put("pm10", "PM10");
    map.put("co", "CarbonMonoxide");
    map.put("no2", "NitrogenDioxide");
    map.put("o3", "Ozone");
    return map;//  www. j  a va  2s . co m
}

From source file:ether.RDFHelper.java

private static HashMap<String, String> createMap_level() {
    HashMap<String, String> map = new HashMap<String, String>();
    map.put("", "Low");
    map.put("?", "Medium");
    map.put("", "High");
    map.put("", "VeryHigh");
    map.put("? ", "Severe");
    return map;//  w w w.j  a v a2s.c o m
}

From source file:Main.java

/**
 * Extract parameters from an uri using parameter name as name
 * @param uri An uri from which extract parameters
 * @return The parameters list/*from  w  w  w  . ja va2 s.c om*/
 */
public static HashMap<String, String> getParameters(String uri) {
    // split each parameter in a string array
    String parameterString[] = uri.split("&");
    HashMap<String, String> params = new HashMap<String, String>();

    // store parameter in parameters map
    // first string if the parameter name, second is the parameter value
    for (String p : parameterString) {
        String paramPair[] = p.split("=");
        params.put(paramPair[0], paramPair[1]);
    }

    return params;
}