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:Main.java

public static <KEY, VALUE> HashMap<KEY, VALUE> newHashMap(KEY key, VALUE value) {
    final HashMap<KEY, VALUE> map = newHashMapSized(1);
    map.put(key, value);
    return map;// w  w w. ja  v a  2s  .c om
}

From source file:Main.java

public static <KEY, VALUE> HashMap<KEY, VALUE> newHashMap(KEY key1, VALUE value1, KEY key2, VALUE value2) {
    final HashMap<KEY, VALUE> map = newHashMapSized(2);
    map.put(key1, value1);
    map.put(key2, value2);// w  ww .  ja va2 s  . c  om
    return map;
}

From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessDataGetterN3Map.java

public static HashMap<String, String> getDataGetterTypeToProcessorMap() {
    HashMap<String, String> map = new HashMap<String, String>();
    map.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SparqlQueryDataGetter",
            "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessSparqlDataGetterN3");
    map.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.ClassGroupPageData",
            "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessClassGroupDataGetterN3");
    map.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.IndividualsForClassesDataGetter",
            "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessIndividualsForClassesDataGetterN3");
    map.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.FixedHTMLDataGetter",
            "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessFixedHTMLN3");
    map.put("edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SearchIndividualsDataGetter",
            "edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessSearchIndividualsDataGetterN3");

    return map;//from w  w  w .  j  av  a 2  s .c  o m
}

From source file:de.beyondjava.Main.java

/**
 * Allows the use of @Scope("view") on Spring @Component, @Service and @Controller
 * beans/*from   w w  w.jav a  2 s. c  om*/
 */
@Bean
public static CustomScopeConfigurer scopeConfigurer() {
    CustomScopeConfigurer configurer = new CustomScopeConfigurer();
    HashMap<String, Object> hashMap = new HashMap<String, Object>();
    hashMap.put("view", viewScope());
    configurer.setScopes(hashMap);
    return configurer;
}

From source file:Main.java

public static <K, V> Map<K, V> asMap(K key, V value) {
    HashMap<K, V> result = new HashMap<K, V>(1);
    result.put(key, value);
    return result;
}

From source file:Main.java

public static ArrayList<Map<String, Object>> drawerContentToMap(ArrayList<String> content) {
    ArrayList<Map<String, Object>> items = new ArrayList<Map<String, Object>>();

    for (String drawerItem : content) {
        HashMap<String, Object> item = new HashMap<String, Object>();
        item.put("drawer_link_name", drawerItem);
        items.add(item);/*from ww  w .  j  av a  2 s .  c  om*/
    }

    return items;
}

From source file:Main.java

public static HashMap<String, String> restoreDistanceAndLocation(Context context) {
    SharedPreferences sharedPref = context.getSharedPreferences("DistanceAndLocation", Context.MODE_PRIVATE);
    String[] keyList = { "longitude", "latitude", "kmTravelled" };
    HashMap<String, String> values = new HashMap<>();
    for (String key : keyList)
        values.put(key, sharedPref.getString(key, null));
    return values;
}

From source file:Main.java

public static <T, K> Map<T, K> toMap(Collection<Entry<T, K>> entryCollection) {
    HashMap<T, K> map = new HashMap<>();
    for (Entry<T, K> entry : entryCollection) {
        map.put(entry.getKey(), entry.getValue());
    }/*from   w  w  w . j av a 2s .co m*/
    return map;
}

From source file:Main.java

public static <T> HashMap<T, T> toMap(T[][] ts) {
    HashMap<T, T> out = new HashMap<T, T>(ts.length);
    for (int i = 0; i < ts.length; i++)
        out.put(ts[i][0], ts[i][1]);
    return out;//  w  ww .  j  av  a  2 s  .  c  om
}

From source file:Main.java

@SafeVarargs
public static <T> HashMap<T, T> kvMap(T... kvPairs) {
    HashMap<T, T> map = new HashMap<>();
    for (int i = 0; i < kvPairs.length; i += 2) {
        map.put(kvPairs[i], kvPairs[i + 1]);
    }/*from w ww . jav a 2s.  c o m*/
    return map;
}