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:net.duckling.ddl.web.sync.JsonResponse.java

public static void chunkUploadSessionNotFound(HttpServletResponse response, String sessionId) {
    HashMap<String, Object> map = new HashMap<String, Object>();
    map.put("sessionId", sessionId);
    map.put("status", "session_not_found");
    Result<Map<String, Object>> result = new Result<Map<String, Object>>(Result.CODE_PARAM_ERROR,
            Result.MESSAGE_PARAM_ERROR, map);
    JsonUtil.writeJSONObject(response, result);
}

From source file:Main.java

private static void saveMetadata(MediaMetadataRetriever metadataRetriever, HashMap<String, String> metadata,
        int metadataKey) {
    String value = metadataRetriever.extractMetadata(metadataKey);
    if (value != null)
        metadata.put(Integer.toString(metadataKey), value);
}

From source file:net.duckling.ddl.web.sync.JsonResponse.java

public static void ackChunk(HttpServletResponse response, String sessionId, String ack, Set<Integer> chunkSet) {
    HashMap<String, Object> map = new HashMap<String, Object>();
    map.put("chunk_ack", ack);
    if (CollectionUtils.isNotEmpty(chunkSet)) {
        map.put("chunk_map", chunkSet);
    }/* ww  w  .  j a v  a  2 s.co m*/

    JsonUtil.writeJSONObject(response, new Result<Map<String, Object>>(map));
}

From source file:Main.java

private static HashMap<Date, Date> getBookedTimeInOneDate(HashMap<Date, Date> bookedTimes, Date date) {
    HashMap<Date, Date> result = new HashMap<Date, Date>();
    for (Date key : bookedTimes.keySet()) {
        if (isSameDay(key, date)) {
            result.put(key, bookedTimes.get(key));
        }/*from   www  .  ja va  2  s.c om*/
    }
    return result;
}

From source file:com.zimbra.cs.util.yauth.TokenAuthenticateV1.java

/**
 * @param username//ww  w .j  av  a 2s  . c  o  m
 * @param passwd
 * @return The token
 */
public static String getToken(String username, String passwd) throws IOException, HttpException {
    GetMethod method = new GetMethod(
            "https://login.yahoo.com/config/pwtoken_get?src=ymsgr&login=" + username + "&passwd=" + passwd);
    int response = HttpClientUtil.executeMethod(method);

    if (response >= 200 && response < 300) {
        String body = method.getResponseBodyAsString();

        HashMap<String, String> map = new HashMap<String, String>();
        map.put("ymsgr", null);

        parseResponseBody(body, map);

        return map.get("ymsgr");
    } else {
        throw new IOException("HTTPClient response: " + response);
    }
}

From source file:com.clz.share.sec.util.SignInUtils.java

public static ResponseEntity<?> signinOauth2(String userId) {

    HashMap<String, String> parameters = new HashMap<String, String>();
    parameters.put("client_id", "appid");
    parameters.put("client_secret", "myOAuthSecret");
    parameters.put("grant_type", "password");
    parameters.put("username", "user");
    parameters.put("password", "pass");
    parameters.put("scope", "read write");

    Principal principal = signinPrivate(userId);
    System.out.println("         pricipal  " + principal.getName());

    ResponseEntity<?> res = null;//from  w ww . j  a  va2  s  .c o m
    try {
        return getToken(principal);
    } catch (HttpRequestMethodNotSupportedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return res;
}

From source file:com.zimbra.cs.util.yauth.TokenAuthenticateV1.java

/**
 * @param username//  w  w w. ja  v a 2s  . c  o  m
 * @param token THIS IS NOT THE PASSWORD -- use the static getToken() method
 *              to get the user's token
 * @return
 */
public static TokenAuthenticateV1 doAuth(String username, String token) throws IOException, HttpException {
    GetMethod method = new GetMethod("https://login.yahoo.com/config/pwtoken_login?src=ymsgr&token=" + token);
    int response = HttpClientUtil.executeMethod(method);

    if (response >= 200 && response < 300) {
        String body = method.getResponseBodyAsString();

        HashMap<String, String> map = new HashMap<String, String>();
        map.put("crumb", null);
        map.put("Y", null);
        map.put("T", null);

        parseResponseBody(body, map);

        return new TokenAuthenticateV1(map.get("crumb"), map.get("Y"), map.get("T"));
    } else {
        throw new IOException("HTTPClient response: " + response);
    }
}

From source file:marshalsec.gadgets.ToStringUtil.java

public static Object makeJohnzonToStringTrigger(Object o) throws Exception {
    Class<?> clz = Class.forName("org.apache.johnzon.core.JsonObjectImpl"); //$NON-NLS-1$
    Constructor<?> dec = clz.getDeclaredConstructor(Map.class);
    dec.setAccessible(true);/*w  w w .  j  av a2s.co  m*/
    HashMap<Object, Object> m = new HashMap<>();
    Object jo = dec.newInstance(m);
    m.put(o, o);
    XString toStringTrig = new XString("");
    return Arrays.asList(jo, JDKUtil.makeMap(jo, toStringTrig));
}

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.j  av a  2 s .  com*/
    incrementHashMap(map2, key2, n);
}

From source file:Main.java

public static HashMap<String, String> parseStringMapResource(Context ctx, int stringArrayResourceId) {
    String[] stringArray = ctx.getResources().getStringArray(stringArrayResourceId);
    HashMap<String, String> map = new HashMap<>(stringArray.length);
    for (String entry : stringArray) {
        String[] splitResult = entry.split("\\|", 2);
        map.put(splitResult[0], splitResult[1]);
    }//from   w  w w  .j a  va  2  s . c  o m
    return map;
}