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:com.facebook.tsdb.tsdash.server.model.MetricQuery.java

public static HashMap<String, String> decodeTags(JSONObject tagsObj) {
    HashMap<String, String> tags = new HashMap<String, String>();
    for (Object tagKeyObj : tagsObj.keySet()) {
        tags.put((String) tagKeyObj, (String) tagsObj.get(tagKeyObj));
    }//  www  . j a  v a  2  s  . co m
    return tags;
}

From source file:com.nuance.expertassistant.InvokeQACoreAPI.java

public static String getContextID(String ProjectID) {

    System.out.println(" The project id is :" + ProjectID);

    url = LoadConfig.getValueFromFile("QACORE_URL", "https://db.tt/hVkpsluN");
    HashMap<String, String> paramMap = new HashMap<String, String>();
    paramMap.put("projectId", ProjectID);
    String localurl = url + "context?";

    System.out.println(" The project URL is :" + url);

    try {//from w  w w  .j a v a 2s  . c  om
        String ContextID = HTTPConnection.sendPost(localurl, paramMap);

        System.out.println(" The context ID is :" + ContextID);

        if (ContextID != null && !ContextID.isEmpty()) {
            return ContextID;
        } else {
            return null;
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;

}

From source file:edu.cornell.mannlib.vitro.webapp.utils.ConceptSearchService.ConceptSearchServiceUtils.java

public static HashMap<String, VocabSourceDescription> getVocabSources() {
    HashMap<String, VocabSourceDescription> map = new HashMap<String, VocabSourceDescription>();
    map.put(UMLSVocabSource, new VocabSourceDescription("UMLS", UMLSVocabSource,
            "http://www.nlm.nih.gov/research/umls/", "Unified Medical Language System"));
    //Commenting out agrovoc for now until implementation is updated
    map.put(AgrovocVocabSource, new VocabSourceDescription("AGROVOC", AgrovocVocabSource,
            "http://www.fao.org/agrovoc/", "Agricultural Vocabulary"));
    map.put(GemetVocabSource, new VocabSourceDescription("GEMET", GemetVocabSource,
            "http://www.eionet.europa.eu/gemet", "GEneral Multilingual Environmental Thesaurus"));
    map.put(LCSHVocabSource, new VocabSourceDescription("LCSH", LCSHVocabSource,
            "http://id.loc.gov/authorities/subjects/", "Library of Congress Subject Headings"));

    return map;//from  w  w  w.j av a  2  s . com
}

From source file:modelo.ApiManager.java

public static List resultSetToArrayList(ResultSet rs) throws SQLException {
    ResultSetMetaData md = rs.getMetaData();
    int columns = md.getColumnCount();
    ArrayList list = new ArrayList();

    while (rs.next()) {
        HashMap row = new HashMap(columns);
        for (int i = 1; i <= columns; ++i) {
            row.put(md.getColumnName(i), rs.getObject(i));
        }/*from www.j ava 2 s. c  om*/
        list.add(row);
    }

    return list;
}

From source file:Main.java

/**
 * Returns a new map with all entries of the input map except those which have a value of null.<p>
 * //from w  w w  . j  av a  2 s.c om
 * @param <A> the key type of the map
 * @param <B> the value type of the map 
 * @param map the input map
 *  
 * @return a map with all null entries removed 
 */
public static <A, B> Map<A, B> removeNullEntries(Map<A, B> map) {

    HashMap<A, B> result = new HashMap<A, B>();

    for (Map.Entry<A, B> entry : map.entrySet()) {
        if (entry.getValue() != null) {
            result.put(entry.getKey(), entry.getValue());
        }
    }
    return result;
}

From source file:com.github.rmsy.alertafk.AlertAFK.java

private static void setUpPlayers(HashMap hm, Player[] p) {
    for (Player aP : p) {
        hm.put(aP.getName(), new AAPlayer(aP));
    }/*w  w  w  . j  a  va  2 s . co m*/
}

From source file:com.o2d.pkayjava.editor.CustomExceptionHandler.java

public static void sendError(String stacktrace) {
    HashMap<String, String> parameters = new HashMap<String, String>();
    parameters.put("error", stacktrace);
    parameters.put("system", SystemUtils.OS_NAME + " " + SystemUtils.OS_VERSION);
    parameters.put("version", AppConfig.getInstance().version);
    HttpRequest httpGet = new HttpRequest(HttpMethods.GET);
    httpGet.setUrl(sendURL);//w  w  w.j  ava  2  s .  c o m
    httpGet.setContent(HttpParametersUtils.convertHttpParameters(parameters));
    Gdx.net.sendHttpRequest(httpGet, new HttpResponseListener() {
        public void handleHttpResponse(HttpResponse httpResponse) {
            //showErrorDialog();
        }

        public void failed(Throwable t) {

        }

        @Override
        public void cancelled() {

        }
    });

}

From source file:io.teak.sdk.RemoteConfiguration.java

public static void requestConfigurationForApp(final Session session) {
    HashMap<String, Object> payload = new HashMap<>();
    payload.put("id", session.appConfiguration.appId);

    new Thread(new Request("gocarrot.com", "/games/" + session.appConfiguration.appId + "/settings.json",
            payload, session) {//  ww w.j  av  a2s. com
        @Override
        protected void done(int responseCode, String responseBody) {
            try {
                JSONObject response = new JSONObject(responseBody);

                RemoteConfiguration configuration = new RemoteConfiguration(session.appConfiguration,
                        response.isNull("auth") ? "gocarrot.com" : response.getString("auth"),
                        nullInsteadOfEmpty(response.isNull("sdk_sentry_dsn") ? null
                                : response.getString("sdk_sentry_dsn")),
                        nullInsteadOfEmpty(response.isNull("app_sentry_dsn") ? null
                                : response.getString("app_sentry_dsn")));

                synchronized (eventListenersMutex) {
                    for (EventListener e : RemoteConfiguration.eventListeners) {
                        e.onConfigurationReady(configuration);
                    }
                }
            } catch (Exception e) {
                Log.e(LOG_TAG, "Error processing settings.json " + Log.getStackTraceString(e));
            }
        }
    }).start();
}

From source file:Main.java

public static HashMap<String, String> valueOf(String classpathAsString) {
    HashMap<String, String> variables = new HashMap<String, String>();
    String[] strings = classpathAsString.split("=");
    for (int i = 0, j = 1; j <= strings.length - 1; i++, j++) {
        variables.put(strings[i], strings[j]);
    }/*from w w w . java2 s.c  o m*/
    return variables;
}

From source file:Main.java

/**
 * Parse a string-array resource with items like this: <item>key|value</item>
 * @param ctx//w w  w .jav a 2 s  . com
 * @param stringArrayResourceId
 * @return the keys=>values as an HashMap
 */
public static HashMap<String, String> parseStringMapResource(Context ctx, int stringArrayResourceId) {
    String[] stringArray = ctx.getResources().getStringArray(stringArrayResourceId);
    HashMap<String, String> map = new HashMap<String, String>(stringArray.length);
    for (String entry : stringArray) {
        String[] splitResult = entry.split("\\|", 2);
        map.put(splitResult[0], splitResult[1]);
    }
    return map;
}